X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fgnutls.c;h=1bf4aefdbfdb17251eb8955f74a28065d99aef90;hb=ea965339038ddc3c8646811351b1a482b8fb296b;hp=17c7c9287662b10292cc5c7b22babd33b3ae750e;hpb=75c6ca0f5d1cc9baf604ed44f1a7b68a0373357d;p=wget diff --git a/src/gnutls.c b/src/gnutls.c index 17c7c928..1bf4aefd 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -104,7 +104,8 @@ ssl_init () return true; } -struct wgnutls_transport_context { +struct wgnutls_transport_context +{ gnutls_session session; /* GnuTLS session handle */ int last_error; /* last error returned by read/write/... */ @@ -144,6 +145,7 @@ wgnutls_read (int fd, char *buf, int bufsize, void *arg) if (ret < 0) ctx->last_error = ret; + return ret; } @@ -184,13 +186,19 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg) { do { - if (gnutls_record_check_pending (ctx->session) - || select_fd (fd, 0, WAIT_FOR_READ)) - ret = gnutls_record_recv (ctx->session, buf + offset, - bufsize - offset); + ret = gnutls_record_recv (ctx->session, buf + offset, + bufsize - offset); } while (ret == GNUTLS_E_INTERRUPTED); + if (ret < 0) + { + if (offset) + ret = 0; + else + return ret; + } + if (ret > 0) { memcpy (ctx->peekbuf + offset, buf + offset, @@ -222,7 +230,8 @@ wgnutls_close (int fd, void *arg) /* gnutls_transport is the singleton that describes the SSL transport methods provided by this file. */ -static struct transport_implementation wgnutls_transport = { +static struct transport_implementation wgnutls_transport = +{ wgnutls_read, wgnutls_write, wgnutls_poll, wgnutls_peek, wgnutls_errstr, wgnutls_close };