[svn] dirmngr - r319 - in trunk: . jnlib src

svn author wk cvs at cvs.gnupg.org
Mon Jul 20 21:06:45 CEST 2009


Author: wk
Date: 2009-07-20 21:06:44 +0200 (Mon, 20 Jul 2009)
New Revision: 319

Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/jnlib/ChangeLog
   trunk/jnlib/logging.c
   trunk/jnlib/logging.h
   trunk/src/ChangeLog
   trunk/src/dirmngr.c
Log:
Put the connection's fd into all log lines.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-07-20 16:37:12 UTC (rev 318)
+++ trunk/ChangeLog	2009-07-20 19:06:44 UTC (rev 319)
@@ -1,3 +1,7 @@
+2009-06-18  Werner Koch  <wk at g10code.com>
+
+	* configure.ac: Fix some URL hints.
+
 2009-06-17  Werner Koch  <wk at g10code.com>
 
 	Released 1.0.3.

Modified: trunk/jnlib/ChangeLog
===================================================================
--- trunk/jnlib/ChangeLog	2009-07-20 16:37:12 UTC (rev 318)
+++ trunk/jnlib/ChangeLog	2009-07-20 19:06:44 UTC (rev 319)
@@ -1,3 +1,9 @@
+2009-07-20  Werner Koch  <wk at g10code.com>
+
+	* logging.c (pid_suffix_cb): New.
+	(log_set_pid_suffix_cb): New.
+	(do_logv): Use it.
+
 2009-06-17  Werner Koch  <wk at g10code.com>
 
 	* Makefile.am (libjnlib_a_SOURCES): Remove unused dotlock module.

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-07-20 16:37:12 UTC (rev 318)
+++ trunk/src/ChangeLog	2009-07-20 19:06:44 UTC (rev 319)
@@ -1,5 +1,9 @@
 2009-07-20  Werner Koch  <wk at g10code.com>
 
+	* dirmngr.c (pid_suffix_callback): New.
+	(main): Use log_set_pid_suffix_cb.
+	(start_connection_thread): Put the fd into the tls.
+
 	* ldap.c (ldap_wrapper_thread): Print ldap worker stati.
 	(ldap_wrapper_release_context): Print a debug info.
 	(end_cert_fetch_ldap): Release the reader.  Might fix bug#999.

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2009-07-20 16:37:12 UTC (rev 318)
+++ trunk/configure.ac	2009-07-20 19:06:44 UTC (rev 319)
@@ -402,7 +402,7 @@
 ***  
 *** You need libgpg-error to build this program.
 **  This library is for example available at
-***   ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
+***   ftp://ftp.gnupg.org/gcrypt/libgpg-error
 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
 ***]])
 fi
@@ -412,7 +412,7 @@
 ***  
 *** You need libgcrypt to build this program.
 **  This library is for example available at
-***   ftp://ftp.gnupg.org/pub/gcrypt/libgcrypt/
+***   ftp://ftp.gnupg.org/gcrypt/libgcrypt/
 *** (at least version $NEED_LIBGCRYPT_VERSION using API $NEED_LIBGCRYPT_API is required.)
 ***]])
 fi
@@ -422,7 +422,7 @@
 ***
 *** You need libassuan to build this program.
 *** This library is for example available at
-***   ftp://ftp.gnupg.org/pub/gcrypt/libassuan/
+***   ftp://ftp.gnupg.org/gcrypt/libassuan/
 *** (at least version $NEED_LIBASSUAN_VERSION is required).
 *** Note, that libassuan must have been build with Pth support.
 ***]])
@@ -433,7 +433,7 @@
 ***
 *** You need libksba to build this program.
 *** This library is for example available at
-***   ftp://ftp.gnupg.org/pub/gcrypt/libksba/
+***   ftp://ftp.gnupg.org/gcrypt/libksba/
 *** (at least version $NEED_KSBA_VERSION using API $NEED_KSBA_API is required.)
 ***]])
 fi

Modified: trunk/jnlib/logging.c
===================================================================
--- trunk/jnlib/logging.c	2009-07-20 16:37:12 UTC (rev 318)
+++ trunk/jnlib/logging.c	2009-07-20 19:06:44 UTC (rev 319)
@@ -61,6 +61,7 @@
 static int with_time;
 static int with_prefix;
 static int with_pid;
+static int (*pid_suffix_cb)(int*);
 static int running_detached;
 static int force_prefixes;
 
@@ -84,7 +85,7 @@
 }
 
 
-/* The follwing 3 functions are used by funopen to write logs to a
+/* The following 3 functions are used by funopen to write logs to a
    socket. */
 #ifdef USE_FUNWRITER
 struct fun_cookie_s {
@@ -364,6 +365,11 @@
   set_file_fd (NULL, fd);
 }
 
+void
+log_set_pid_suffix_cb (int (*fnc)(int *pidsuf))
+{
+  pid_suffix_cb = fnc;
+}
 
 void
 log_set_prefix (const char *text, unsigned int flags)
@@ -460,7 +466,15 @@
       if (with_prefix || force_prefixes)
         fputs (prefix_buffer, logstream);
       if (with_pid || force_prefixes)
-        fprintf (logstream, "[%u]", (unsigned int)getpid ());
+        {
+          unsigned int apid = (unsigned int)getpid ();
+          int pidsuf;
+
+          if (pid_suffix_cb && pid_suffix_cb (&pidsuf))
+            fprintf (logstream, "[%u.%d]", apid, pidsuf);
+          else
+            fprintf (logstream, "[%u]", apid);
+        }
       if (!with_time || force_prefixes)
         putc (':', logstream);
       /* A leading backspace suppresses the extra space so that we can

Modified: trunk/jnlib/logging.h
===================================================================
--- trunk/jnlib/logging.h	2009-07-20 16:37:12 UTC (rev 318)
+++ trunk/jnlib/logging.h	2009-07-20 19:06:44 UTC (rev 319)
@@ -35,6 +35,7 @@
 void log_inc_errorcount (void);
 void log_set_file( const char *name );
 void log_set_fd (int fd);
+void log_set_pid_suffix_cb (int (*fnc)(int *pidsuf));
 void log_set_prefix (const char *text, unsigned int flags);
 const char *log_get_prefix (unsigned int *flags);
 int log_test_fd (int fd);

Modified: trunk/src/dirmngr.c
===================================================================
--- trunk/src/dirmngr.c	2009-07-20 16:37:12 UTC (rev 318)
+++ trunk/src/dirmngr.c	2009-07-20 19:06:44 UTC (rev 319)
@@ -239,6 +239,13 @@
 #endif
 
 
+/* The key used to store the current file descriptor in the thread
+   local storage.  We use this in conjunction with the
+   log_set_pid_suffix_cb feature..  */
+#ifndef HAVE_W32_SYSTEM
+static int my_tlskey_current_fd;
+#endif
+
 /* Prototypes. */
 static void cleanup (void);
 static ldap_server_t parse_ldapserver_file (const char* filename);
@@ -547,7 +554,16 @@
 }
 #endif /*HAVE_W32_SYSTEM*/
 
+#ifndef HAVE_W32_SYSTEM
+static int
+pid_suffix_callback (int *r_suffix)
+{
+  *r_suffix = (int)pth_key_getdata (my_tlskey_current_fd);
+  return (*r_suffix != -1);
+}
+#endif /*!HAVE_W32_SYSTEM*/
 
+
 #ifdef HAVE_W32_SYSTEM
 #define main real_main
 #endif
@@ -602,7 +618,7 @@
 
   set_strusage (my_strusage);
   log_set_prefix ("dirmngr", 1|4); 
-  
+
   /* Check that the libraries are suitable.  Do it here because
      the option parsing may need services of the libraries. */
 
@@ -650,9 +666,18 @@
   shell = getenv ("SHELL");
   if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
     csh_style = 1;
-  
+
   opt.homedir = default_homedir ();
 
+  /* Now with Pth running we can set the logging callback.  Our
+     windows implementation does not yet feature the PTh tls
+     functions.  */
+#ifndef HAVE_W32_SYSTEM
+  if (pth_key_create (&my_tlskey_current_fd, NULL))
+    if (pth_key_setdata (my_tlskey_current_fd, NULL))
+      log_set_pid_suffix_cb (pid_suffix_callback);
+#endif /*!HAVE_W32_SYSTEM*/
+  
   /* Reset rereadable options to default values. */
   parse_rereadable_options (NULL, 0); 
 
@@ -1663,6 +1688,10 @@
   if (check_nonce (fd, &socket_nonce))
     return NULL;
 
+#ifndef HAVE_W32_SYSTEM
+  pth_key_setdata (my_tlskey_current_fd, (void*)FD2INT (fd));
+#endif
+
   active_connections++;
   if (opt.verbose)
     log_info (_("handler for fd %d started\n"), FD2INT (fd));
@@ -1672,6 +1701,10 @@
   if (opt.verbose)
     log_info (_("handler for fd %d terminated\n"), FD2INT (fd));
   active_connections--;
+
+#ifndef HAVE_W32_SYSTEM
+  pth_key_setdata (my_tlskey_current_fd, (void*)(-1));
+#endif
   
   return NULL;
 }




More information about the Gnupg-commits mailing list