mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Make wgnutls_peek non blocking.
This commit is contained in:
parent
28db25933b
commit
ca244196f1
@ -1,3 +1,7 @@
|
||||
2011-04-03 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* bootstrap.conf (gnulib_modules): Add `fcntl'.
|
||||
|
||||
2011-03-26 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* configure.ac: Fix the gnutls detection.
|
||||
|
@ -32,6 +32,7 @@ bind
|
||||
c-ctype
|
||||
close
|
||||
connect
|
||||
fcntl
|
||||
getaddrinfo
|
||||
getopt-gnu
|
||||
getpass-gnu
|
||||
|
@ -1,3 +1,8 @@
|
||||
2011-04-03 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* gnutls.c: Include <fcntl.h>
|
||||
(wgnutls_peek): Make the socket non blocking before attempt a read.
|
||||
|
||||
2011-03-31 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* recur.c (download_child_p): When --no-parent is used, check that the
|
||||
|
14
src/gnutls.c
14
src/gnutls.c
@ -40,6 +40,7 @@ as that of the covered work. */
|
||||
|
||||
#include <gnutls/gnutls.h>
|
||||
#include <gnutls/x509.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "connect.h"
|
||||
@ -182,6 +183,15 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg)
|
||||
|
||||
if (bufsize > offset)
|
||||
{
|
||||
int flags;
|
||||
flags = fcntl (fd, F_GETFL, 0);
|
||||
if (flags < 0)
|
||||
return ret;
|
||||
|
||||
ret = fcntl (fd, F_SETFL, flags | O_NONBLOCK);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
do
|
||||
{
|
||||
ret = gnutls_record_recv (ctx->session, buf + offset,
|
||||
@ -203,6 +213,10 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg)
|
||||
ret);
|
||||
ctx->peeklen += ret;
|
||||
}
|
||||
|
||||
fcntl (fd, F_SETFL, flags);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return offset + ret;
|
||||
|
Loading…
Reference in New Issue
Block a user