aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-11-07 17:21:50 +0000
committerWerner Koch <[email protected]>2014-11-07 17:21:50 +0000
commitf0f5cb6b3e525f696b8820c517190e1d84f3b885 (patch)
tree0b3603e4414079ba58d0054d519b0d2a133ad405
parentbuild: Add method to use a custom swdb.lst and use adns with Windows. (diff)
downloadgnupg-f0f5cb6b3e525f696b8820c517190e1d84f3b885.tar.gz
gnupg-f0f5cb6b3e525f696b8820c517190e1d84f3b885.zip
w32: Fix http access module.
* common/http.c (write_server) [W32]: Rework to use send() instead of write even when build with npth. (cookie_read) [W32]: Rework to use recv() instead of read even when build with npth.
Diffstat (limited to '')
-rw-r--r--common/http.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/common/http.c b/common/http.c
index 413efd840..f129010b3 100644
--- a/common/http.c
+++ b/common/http.c
@@ -2320,14 +2320,20 @@ write_server (int sock, const char *data, size_t length)
nleft = length;
while (nleft > 0)
{
-#if defined(HAVE_W32_SYSTEM) && !defined(USE_NPTH)
+#if defined(HAVE_W32_SYSTEM)
+# if defined(USE_NPTH)
+ npth_unprotect ();
+# endif
nwritten = send (sock, data, nleft, 0);
+# if defined(USE_NPTH)
+ npth_protect ();
+# endif
if ( nwritten == SOCKET_ERROR )
{
log_info ("network write failed: ec=%d\n", (int)WSAGetLastError ());
return gpg_error (GPG_ERR_NETWORK);
}
-#else /*!HAVE_W32_SYSTEM || USE_NPTH*/
+#else /*!HAVE_W32_SYSTEM*/
# ifdef USE_NPTH
nwritten = npth_write (sock, data, nleft);
# else
@@ -2349,7 +2355,7 @@ write_server (int sock, const char *data, size_t length)
log_info ("network write failed: %s\n", strerror (errno));
return gpg_error_from_syserror ();
}
-#endif /*!HAVE_W32_SYSTEM || USE_NPTH*/
+#endif /*!HAVE_W32_SYSTEM*/
nleft -= nwritten;
data += nwritten;
}
@@ -2404,14 +2410,25 @@ cookie_read (void *cookie, void *buffer, size_t size)
{
do
{
-#ifdef USE_NPTH
- nread = npth_read (c->sock->fd, buffer, size);
-#elif defined(HAVE_W32_SYSTEM)
+#ifdef HAVE_W32_SYSTEM
/* Under Windows we need to use recv for a socket. */
+# if defined(USE_NPTH)
+ npth_unprotect ();
+# endif
nread = recv (c->sock->fd, buffer, size, 0);
-#else
+# if defined(USE_NPTH)
+ npth_protect ();
+# endif
+
+#else /*!HAVE_W32_SYSTEM*/
+
+# ifdef USE_NPTH
+ nread = npth_read (c->sock->fd, buffer, size);
+# else
nread = read (c->sock->fd, buffer, size);
-#endif
+# endif
+
+#endif /*!HAVE_W32_SYSTEM*/
}
while (nread == -1 && errno == EINTR);
}