From b1acde223fb705a0b14b3f14e368c64e9d58ed01 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sun, 3 Apr 2011 20:23:31 +0200 Subject: [PATCH] Fix build under Windows. --- ChangeLog | 2 ++ bootstrap.conf | 1 + configure.ac | 2 +- src/ChangeLog | 7 ++++++- src/gnutls.c | 17 ++++++++++++++++- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba5af9ab..27e1d068 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * bootstrap.conf (gnulib_modules): Add `fcntl'. + (gnulib_modules): Add `ioctl'. + 2011-03-26 Giuseppe Scrivano * configure.ac: Fix the gnutls detection. diff --git a/bootstrap.conf b/bootstrap.conf index 3fb3bdfb..70fdfb70 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -39,6 +39,7 @@ getpass-gnu getpeername getsockname gnupload +ioctl iconv-h listen maintainer-makefile diff --git a/configure.ac b/configure.ac index 2c01089f..205b6533 100644 --- a/configure.ac +++ b/configure.ac @@ -223,7 +223,7 @@ WGET_NSL_SOCKET dnl Deal with specific hosts case $host_os in *mingw32* ) - AC_SUBST(W32LIBS, '-lws2_32') + AC_SUBST(W32LIBS, '-lws2_32 -lgdi32') AC_LIBOBJ([mswindows]) ;; esac diff --git a/src/ChangeLog b/src/ChangeLog index ef3a863b..4c0ff9cd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,8 +1,13 @@ 2011-04-03 Giuseppe Scrivano - * gnutls.c: Include + * gnutls.c: Include . (wgnutls_peek): Make the socket non blocking before attempt a read. + * gnutls.c: Include . + (wgnutls_peek) [F_GETFL]: Use fcntl. + (wgnutls_peek) [! F_GETFL]: Use ioctl. + + 2011-03-31 Giuseppe Scrivano * recur.c (download_child_p): When --no-parent is used, check that the diff --git a/src/gnutls.c b/src/gnutls.c index 4f38aca1..2e5f89a7 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -41,6 +41,7 @@ as that of the covered work. */ #include #include #include +#include #include "utils.h" #include "connect.h" @@ -183,6 +184,7 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg) if (bufsize > offset) { +#ifdef F_GETFL int flags; flags = fcntl (fd, F_GETFL, 0); if (flags < 0) @@ -191,7 +193,13 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg) ret = fcntl (fd, F_SETFL, flags | O_NONBLOCK); if (ret < 0) return ret; - +#else + /* XXX: Assume it was blocking before. */ + const int zero = 0; + ret = ioctl (fd, FIONBIO, &zero); + if (ret < 0) + return ret; +#endif do { ret = gnutls_record_recv (ctx->session, buf + offset, @@ -214,9 +222,16 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg) ctx->peeklen += ret; } +#ifdef F_GETFL fcntl (fd, F_SETFL, flags); if (ret < 0) return ret; +#else + const int one = 1; + ret = ioctl (fd, FIONBIO, &one); + if (ret < 0) + return ret; +#endif } return offset + ret; -- 2.39.2