[svn] dirmngr - r318 - trunk/src

svn author wk cvs at cvs.gnupg.org
Mon Jul 20 18:37:12 CEST 2009


Author: wk
Date: 2009-07-20 18:37:12 +0200 (Mon, 20 Jul 2009)
New Revision: 318

Modified:
   trunk/src/ChangeLog
   trunk/src/ldap.c
Log:
Possible fix for bug#999.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-06-17 14:57:14 UTC (rev 317)
+++ trunk/src/ChangeLog	2009-07-20 16:37:12 UTC (rev 318)
@@ -1,3 +1,9 @@
+2009-07-20  Werner Koch  <wk at g10code.com>
+
+	* 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.
+
 2009-06-17  Werner Koch  <wk at g10code.com>
 
 	* util.h: Remove unused dotlock.h.

Modified: trunk/src/ldap.c
===================================================================
--- trunk/src/ldap.c	2009-06-17 14:57:14 UTC (rev 317)
+++ trunk/src/ldap.c	2009-07-20 16:37:12 UTC (rev 318)
@@ -262,6 +262,7 @@
   for (;;)
     {
       pth_event_t timeout_ev;
+      int any_action = 0;
 
       timeout_ev = pth_event (PTH_EVENT_TIME, pth_timeout (1, 0));
       if (! timeout_ev)
@@ -318,6 +319,7 @@
                   print_log_line (ctx, NULL);
                   log_error (_("error reading log from ldap wrapper %d: %s\n"),
                              ctx->pid, strerror (errno));
+                  any_action = 1;
                 }
               else if (!n) /* EOF */
                 {
@@ -326,6 +328,7 @@
                   ctx->log_fd = -1;
                   pth_event_free (ctx->log_ev, PTH_FREE_THIS);
                   ctx->log_ev = NULL;
+                  any_action = 1;
                 }
               else 
                 {
@@ -351,11 +354,13 @@
                   ctx->ready = 1;
 		  dirmngr_release_process (ctx->pid);
                   ctx->pid = (pid_t)(-1);
+                  any_action = 1;
                 }
               else if (gpg_err_code (err) != GPG_ERR_TIMEOUT)
                 {
                   log_error (_("waiting for ldap wrapper %d failed: %s\n"),
                              (int)ctx->pid, gpg_strerror (err));
+                  any_action = 1;
                 }
             }
 
@@ -367,9 +372,26 @@
                 ctx->stamp = (time_t)(-1);
               log_info (_("ldap wrapper %d stalled - killing\n"),
                         (int)ctx->pid);
+              any_action = 1;
             }
         }
 
+      /* If something has been printed to the log file or we got an
+         EOF from a wrapper, we now print the list of active
+         wrappers.  */
+      if (any_action && DBG_LOOKUP) 
+        {
+          log_info ("ldap worker stati:\n");
+          for (ctx = wrapper_list; ctx; ctx = ctx->next)
+            log_info ("  c=%p pid=%d/%d rdr=%p ctrl=%p/%d la=%lu rdy=%d\n",
+                      ctx, 
+                      (int)ctx->pid, (int)ctx->printable_pid,
+                      ctx->reader,
+                      ctx->ctrl, ctx->ctrl? ctx->ctrl->refcount:0, 
+                      (unsigned long)ctx->stamp, ctx->ready);
+        }
+
+
       /* Use a separate loop to check whether ready marked wrappers
          may be removed.  We may only do so if the ksba reader object
          is not anymore in use or we are in shutdown state.  */
@@ -417,6 +439,13 @@
   for (ctx=wrapper_list; ctx; ctx=ctx->next)
     if (ctx->reader == reader)
       {
+        if (DBG_LOOKUP)
+          log_info ("releasing ldap worker c=%p pid=%d/%d rdr=%p ctrl=%p/%d\n",
+                    ctx, 
+                    (int)ctx->pid, (int)ctx->printable_pid,
+                    ctx->reader,
+                    ctx->ctrl, ctx->ctrl? ctx->ctrl->refcount:0);
+        
         ctx->reader = NULL;
         if (ctx->fd != -1)
           {
@@ -589,8 +618,8 @@
      everything gets intermixed.  Clearly we don't want this.  So the
      only viable solutions are either to have another thread
      responsible for logging the messages or to add an option to the
-     wrapper modules to the logging on its own.  Given that we anyway
-     need a way to rip the child process and this best done using a
+     wrapper module to do the logging on its own.  Given that we anyway
+     need a way to rip the child process and this is best done using a
      general ripping thread, that thread can do the logging too. */
 
   *reader = NULL;
@@ -1420,7 +1449,11 @@
 {
   if (context)
     {
+      ksba_reader_t reader = context->reader;
+
       xfree (context->tmpbuf);
       xfree (context);
+      ldap_wrapper_release_context (reader);
+      ksba_reader_release (reader);
     }
 }




More information about the Gnupg-commits mailing list