[Gpg4win-commits] r1321 - in trunk: . patches/gpgme-1.2.0
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Jan 25 09:19:57 CET 2010
Author: werner
Date: 2010-01-25 09:19:56 +0100 (Mon, 25 Jan 2010)
New Revision: 1321
Added:
trunk/patches/gpgme-1.2.0/03-w32-socket.patch
Modified:
trunk/ChangeLog
trunk/Makefile.am
Log:
gpgme fix
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-01-21 10:08:08 UTC (rev 1320)
+++ trunk/ChangeLog 2010-01-25 08:19:56 UTC (rev 1321)
@@ -1,3 +1,8 @@
+2010-01-22 Werner Koch <wk at g10code.com>
+
+ * patches/gpgme-1.2.0/03-w32-socket.patch: New.
+ * Makefile.am (EXTRA_DIST): Add it.
+
2010-01-15 Colin Leroy <colin at colino.net>
* packages/packages.current: Update libetpan, claws-mail and plugins.
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2010-01-21 10:08:08 UTC (rev 1320)
+++ trunk/Makefile.am 2010-01-25 08:19:56 UTC (rev 1321)
@@ -34,6 +34,7 @@
patches/gpgme-1.1.7/03-error-parsing.patch \
patches/gpgme-1.2.0/01-w32-io-threads.patch \
patches/gpgme-1.2.0/02-inv-signer.patch \
+ patches/gpgme-1.2.0/03-w32-socket.patch \
patches/winpt/01-gpg-path.patch \
patches/gpgex/01-no-checksums.patch \
patches/gpgex-0.9.3/01-full-browser.patch \
Added: trunk/patches/gpgme-1.2.0/03-w32-socket.patch
===================================================================
--- trunk/patches/gpgme-1.2.0/03-w32-socket.patch 2010-01-21 10:08:08 UTC (rev 1320)
+++ trunk/patches/gpgme-1.2.0/03-w32-socket.patch 2010-01-25 08:19:56 UTC (rev 1321)
@@ -0,0 +1,149 @@
+#! /bin/sh
+patch -p0 -f $* < $0
+exit $?
+
+2010-01-22 Werner Koch <wk at g10code.com>
+
+ * w32-io.c (writer): Try to use send first.
+ (reader): Try to use recv first.
+
+
+--- src/w32-io.c (revision 1445)
++++ src/w32-io.c (working copy)
+@@ -49,6 +49,7 @@
+ #define handle_to_fd(a) ((int)(a))
+ #define pid_to_handle(a) ((HANDLE)(a))
+ #define handle_to_pid(a) ((int)(a))
++#define handle_to_socket(a) ((unsigned int)(a))
+
+ #define READBUF_SIZE 4096
+ #define WRITEBUF_SIZE 4096
+@@ -180,6 +181,7 @@
+ struct reader_context_s *ctx = arg;
+ int nbytes;
+ DWORD nread;
++ int try_recv = 1;
+ TRACE_BEG1 (DEBUG_SYSIO, "gpgme:reader", ctx->file_hd,
+ "thread=%p", ctx->thread_hd);
+
+@@ -211,21 +213,52 @@
+ UNLOCK (ctx->mutex);
+
+ TRACE_LOG1 ("reading %d bytes", nbytes);
+- if (!ReadFile (ctx->file_hd,
+- ctx->buffer + ctx->writepos, nbytes, &nread, NULL))
+- {
+- ctx->error_code = (int) GetLastError ();
+- if (ctx->error_code == ERROR_BROKEN_PIPE)
+- {
+- ctx->eof = 1;
+- TRACE_LOG ("got EOF (broken pipe)");
++
++ if (try_recv)
++ {
++ int n;
++
++ n = recv (handle_to_socket (ctx->file_hd),
++ ctx->buffer + ctx->writepos, nbytes, 0);
++ if (n < 0 && WSAGetLastError () == WSAENOTSOCK)
++ try_recv = 0;
++ else if (n < 0)
++ {
++ ctx->error_code = (int) WSAGetLastError ();
++ if (ctx->error_code == ERROR_BROKEN_PIPE)
++ {
++ ctx->eof = 1;
++ TRACE_LOG ("got EOF (broken connection)");
++ }
++ else
++ {
++ ctx->error = 1;
++ TRACE_LOG1 ("recv error: ec=%d", ctx->error_code);
++ }
++ break;
+ }
+- else
+- {
+- ctx->error = 1;
+- TRACE_LOG1 ("read error: ec=%d", ctx->error_code);
++ else
++ nread = n;
++
++ }
++ if (!try_recv)
++ {
++ if (!ReadFile (ctx->file_hd,
++ ctx->buffer + ctx->writepos, nbytes, &nread, NULL))
++ {
++ ctx->error_code = (int) GetLastError ();
++ if (ctx->error_code == ERROR_BROKEN_PIPE)
++ {
++ ctx->eof = 1;
++ TRACE_LOG ("got EOF (broken pipe)");
++ }
++ else
++ {
++ ctx->error = 1;
++ TRACE_LOG1 ("read error: ec=%d", ctx->error_code);
++ }
++ break;
+ }
+- break;
+ }
+ if (!nread)
+ {
+@@ -507,6 +540,7 @@
+ {
+ struct writer_context_s *ctx = arg;
+ DWORD nwritten;
++ int try_send = 1;
+ TRACE_BEG1 (DEBUG_SYSIO, "gpgme:writer", ctx->file_hd,
+ "thread=%p", ctx->thread_hd);
+
+@@ -541,14 +575,37 @@
+ /* Note that CTX->nbytes is not zero at this point, because
+ _gpgme_io_write always writes at least 1 byte before waking
+ us up, unless CTX->stop_me is true, which we catch above. */
+- if (!WriteFile (ctx->file_hd, ctx->buffer,
+- ctx->nbytes, &nwritten, NULL))
+- {
+- ctx->error_code = (int) GetLastError ();
+- ctx->error = 1;
+- TRACE_LOG1 ("write error: ec=%d", ctx->error_code);
+- break;
+- }
++ if (try_send)
++ {
++ /* We need to try send first because a socket handle can't
++ be used with WriteFile. */
++ int n;
++
++ n = send (handle_to_socket (ctx->file_hd),
++ ctx->buffer, ctx->nbytes, 0);
++ if (n < 0 && WSAGetLastError () == WSAENOTSOCK)
++ try_send = 0;
++ else if (n < 0)
++ {
++ ctx->error_code = (int) WSAGetLastError ();
++ ctx->error = 1;
++ TRACE_LOG1 ("send error: ec=%d", ctx->error_code);
++ break;
++ }
++ else
++ nwritten = n;
++ }
++ if (!try_send)
++ {
++ if (!WriteFile (ctx->file_hd, ctx->buffer,
++ ctx->nbytes, &nwritten, NULL))
++ {
++ ctx->error_code = (int) GetLastError ();
++ ctx->error = 1;
++ TRACE_LOG1 ("write error: ec=%d", ctx->error_code);
++ break;
++ }
++ }
+ TRACE_LOG1 ("wrote %d bytes", (int) nwritten);
+
+ LOCK (ctx->mutex);
+
Property changes on: trunk/patches/gpgme-1.2.0/03-w32-socket.patch
___________________________________________________________________
Name: svn:executable
+ *
More information about the Gpg4win-commits
mailing list