[git] GPGME - branch, master, updated. gpgme-1.4.1-4-g9f330be

by Werner Koch cvs at cvs.gnupg.org
Wed May 8 21:03:08 CEST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  9f330be8210d2498fe93d4166b6f6c02fca76475 (commit)
       via  2118f497010a9a41c29d062a7605ff2e136f8f4e (commit)
       via  a7e5f1096f02af7bfb678b0bea8da6ccfc28cc79 (commit)
      from  de30df9ce359202b2449697c7e16dc0311e9050f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9f330be8210d2498fe93d4166b6f6c02fca76475
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Apr 25 12:00:16 2013 +0100

    Fix hang in socket closing.
    
    * src/w32-io.c (destroy_reader): Call shutdown.
    (reader): Do not print an error in the shutdown case.

diff --git a/src/w32-io.c b/src/w32-io.c
index 164205e..776e379 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -316,6 +316,21 @@ reader (void *arg)
                 }
               else
                 {
+                  /* Check whether the shutdown triggered the error -
+                     no need to to print a warning in this case.  */
+                  if ( ctx->error_code == WSAECONNABORTED
+                       || ctx->error_code == WSAECONNRESET)
+                    {
+                      LOCK (ctx->mutex);
+                      if (ctx->stop_me)
+                        {
+                          UNLOCK (ctx->mutex);
+                          TRACE_LOG ("got shutdown");
+                          break;
+                        }
+                      UNLOCK (ctx->mutex);
+                    }
+
                   ctx->error = 1;
                   TRACE_LOG1 ("recv error: ec=%d", ctx->error_code);
                 }
@@ -357,6 +372,7 @@ reader (void *arg)
 	  UNLOCK (ctx->mutex);
 	  break;
         }
+
       TRACE_LOG1 ("got %u bytes", nread);
 
       ctx->writepos = (ctx->writepos + nread) % READBUF_SIZE;
@@ -495,6 +511,26 @@ destroy_reader (struct reader_context_s *ctx)
     }
 #endif
 
+  /* The reader thread is usually blocking in recv or ReadFile.  If
+     the peer does not send an EOF or breaks the pipe the WFSO might
+     get stuck waiting for the termination of the reader thread.  This
+     happens quite often with sockets, thus we definitely need to get
+     out of the recv.  A shutdown does this nicely.  For handles
+     (i.e. pipes) it would also be nice to cancel the operation, but
+     such a feature is only available since Vista.  Thus we need to
+     dlopen that syscall.  */
+  if (ctx->file_hd != INVALID_HANDLE_VALUE)
+    {
+      /* Fixme: Call CancelSynchronousIo (handle_of_thread).  */
+    }
+  else if (ctx->file_sock != INVALID_SOCKET)
+    {
+      if (shutdown (ctx->file_sock, 2))
+        TRACE2 (DEBUG_SYSIO, "gpgme:destroy_reader", ctx->file_hd,
+                "shutdown socket %d failed: %s",
+                ctx->file_sock, (int) WSAGetLastError ());
+    }
+
   TRACE1 (DEBUG_SYSIO, "gpgme:destroy_reader", ctx->file_hd,
 	  "waiting for termination of thread %p", ctx->thread_hd);
   WaitForSingleObject (ctx->stopped, INFINITE);

commit 2118f497010a9a41c29d062a7605ff2e136f8f4e
Author: Werner Koch <wk at gnupg.org>
Date:   Mon May 6 20:23:47 2013 +0200

    Improve debug output of the I/O reader and writer.
    
    * src/w32-io.c (reader, writer): Also print file_sock.

diff --git a/src/w32-io.c b/src/w32-io.c
index cbc3064..164205e 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -264,8 +264,8 @@ reader (void *arg)
   int nbytes;
   DWORD nread;
   int sock;
-  TRACE_BEG1 (DEBUG_SYSIO, "gpgme:reader", ctx->file_hd,
-	      "thread=%p", ctx->thread_hd);
+  TRACE_BEG2 (DEBUG_SYSIO, "gpgme:reader", ctx->file_hd,
+	      "file_sock=%d, thread=%p", ctx->file_sock, ctx->thread_hd);
 
   if (ctx->file_hd != INVALID_HANDLE_VALUE)
     sock = 0;
@@ -400,6 +400,9 @@ create_reader (int fd)
       TRACE_SYSERR (EIO);
       return NULL;
     }
+  TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d",
+              fd, fd_table[fd].handle, fd_table[fd].socket,
+              fd_table[fd].dup_from);
   ctx->file_hd = fd_table[fd].handle;
   ctx->file_sock = fd_table[fd].socket;
 
@@ -652,8 +655,8 @@ writer (void *arg)
   struct writer_context_s *ctx = arg;
   DWORD nwritten;
   int sock;
-  TRACE_BEG1 (DEBUG_SYSIO, "gpgme:writer", ctx->file_hd,
-	      "thread=%p", ctx->thread_hd);
+  TRACE_BEG2 (DEBUG_SYSIO, "gpgme:writer", ctx->file_hd,
+	      "file_sock=%d, thread=%p", ctx->file_sock, ctx->thread_hd);
 
   if (ctx->file_hd != INVALID_HANDLE_VALUE)
     sock = 0;
@@ -766,6 +769,9 @@ create_writer (int fd)
       TRACE_SYSERR (EIO);
       return NULL;
     }
+  TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d",
+              fd, fd_table[fd].handle, fd_table[fd].socket,
+              fd_table[fd].dup_from);
   ctx->file_hd = fd_table[fd].handle;
   ctx->file_sock = fd_table[fd].socket;
 
@@ -1149,6 +1155,10 @@ _gpgme_io_close (int fd)
       return TRACE_SYSRES (-1);
     }
 
+  TRACE_LOG4 ("fd=%d -> handle=%p socket=%d dupfrom=%d",
+              fd, fd_table[fd].handle, fd_table[fd].socket,
+              fd_table[fd].dup_from);
+
   kill_reader (fd);
   kill_writer (fd);
   LOCK (notify_table_lock);
@@ -1544,7 +1554,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
   args = calloc (2 + i + 1, sizeof (*args));
   args[0] = (char *) _gpgme_get_w32spawn_path ();
   args[1] = tmp_name;
-  args[2] = path;
+  args[2] = (char *)path;
   memcpy (&args[3], &argv[1], i * sizeof (*args));
 
   memset (&sec_attr, 0, sizeof sec_attr);
@@ -1734,7 +1744,9 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
   TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_select", fds,
 	      "nfds=%u, nonblock=%u", nfds, nonblock);
 
+#if 0
  restart:
+#endif
   TRACE_SEQ (dbg_help, "select on [ ");
   any = 0;
   nwait = 0;

commit a7e5f1096f02af7bfb678b0bea8da6ccfc28cc79
Author: Werner Koch <wk at gnupg.org>
Date:   Mon May 6 20:22:23 2013 +0200

    Simplify a debug code function.
    
    * src/debug.c (_gpgme_debug): Remove static space string.

diff --git a/src/debug.c b/src/debug.c
index 56effa7..ca0bb21 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -258,17 +258,10 @@ _gpgme_debug (int level, const char *format, ...)
   }
 #ifdef FRAME_NR
   {
-    char spaces[] = "                                        ";
-    int nr_spaces = sizeof (spaces) - 1;
-    int nr_columns;
-
-    nr_columns = 2 * (frame_nr - 1);
-    if (nr_columns > nr_spaces)
-      nr_columns = nr_spaces;
-    if (nr_columns < 0)
-      nr_columns = 0;
-    spaces[nr_columns] = '\0';
-    fprintf (errfp, "%s", spaces);
+    int indent;
+
+    indent = frame_nr > 0? (2 * (frame_nr - 1)):0;
+    fprintf (errfp, "%*s", indent < 40? indent : 40, "");
   }
 #endif
 

-----------------------------------------------------------------------

Summary of changes:
 src/debug.c  |   15 ++++-----------
 src/w32-io.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 57 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list