pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/net/libfetch



Module Name:    pkgsrc
Committed By:   joerg
Date:           Thu Oct 20 21:25:57 UTC 2016

Modified Files:
        pkgsrc/net/libfetch: Makefile
        pkgsrc/net/libfetch/files: common.c common.h

Log Message:
libfetch-2.37: Always run SSL_read first for SSL connections. It will
signal whether more input (or output) is needed, update the poll mask
accordingly.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 pkgsrc/net/libfetch/Makefile
cvs rdiff -u -r1.30 -r1.31 pkgsrc/net/libfetch/files/common.c
cvs rdiff -u -r1.23 -r1.24 pkgsrc/net/libfetch/files/common.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/net/libfetch/Makefile
diff -u pkgsrc/net/libfetch/Makefile:1.56 pkgsrc/net/libfetch/Makefile:1.57
--- pkgsrc/net/libfetch/Makefile:1.56   Sat Mar  5 11:27:52 2016
+++ pkgsrc/net/libfetch/Makefile        Thu Oct 20 21:25:57 2016
@@ -1,8 +1,7 @@
-# $NetBSD: Makefile,v 1.56 2016/03/05 11:27:52 jperkin Exp $
+# $NetBSD: Makefile,v 1.57 2016/10/20 21:25:57 joerg Exp $
 #
 
-DISTNAME=      libfetch-2.36
-PKGREVISION=   3
+DISTNAME=      libfetch-2.37
 CATEGORIES=    net
 MASTER_SITES=  # empty
 DISTFILES=     # empty

Index: pkgsrc/net/libfetch/files/common.c
diff -u pkgsrc/net/libfetch/files/common.c:1.30 pkgsrc/net/libfetch/files/common.c:1.31
--- pkgsrc/net/libfetch/files/common.c:1.30     Thu Oct 20 21:22:18 2016
+++ pkgsrc/net/libfetch/files/common.c  Thu Oct 20 21:25:57 2016
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.c,v 1.30 2016/10/20 21:22:18 joerg Exp $        */
+/*     $NetBSD: common.c,v 1.31 2016/10/20 21:25:57 joerg Exp $        */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Co�dan Sm�rgrav
  * Copyright (c) 2008, 2010 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
@@ -240,6 +240,7 @@ fetch_reopen(int sd)
        conn->next_buf = NULL;
        conn->next_len = 0;
        conn->sd = sd;
+       conn->buf_events = POLLIN;
        return (conn);
 }
 
@@ -456,6 +457,7 @@ fetch_ssl(conn_t *conn, const struct url
                fprintf(stderr, "SSL context creation failed\n");
                return (-1);
        }
+       conn->buf_events = 0;
        SSL_set_fd(conn->ssl, conn->sd);
 #if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
        if (!SSL_set_tlsext_host_name(conn->ssl, (char *)(uintptr_t)URL->host)) {
@@ -537,9 +539,9 @@ fetch_read(conn_t *conn, char *buf, size
        }
 
        pfd.fd = conn->sd;
-       pfd.events = POLLIN;
        for (;;) {
-               if (fetchTimeout) {
+               pfd.events = conn->buf_events;
+               if (fetchTimeout && pfd.events) {
                        do {
                                timeout_cur = compute_timeout(&timeout_end);
                                if (timeout_cur < 0) {
@@ -558,9 +560,26 @@ fetch_read(conn_t *conn, char *buf, size
                        } while (pfd.revents == 0);
                }
 #ifdef WITH_SSL
-               if (conn->ssl != NULL)
+               if (conn->ssl != NULL) {
                        rlen = SSL_read(conn->ssl, buf, len);
-               else
+                       if (rlen == -1) {
+                               switch (SSL_get_error(conn->ssl, rlen)) {
+                               case SSL_ERROR_WANT_READ:
+                                       conn->buf_events = POLLIN;
+                                       break;
+                               case SSL_ERROR_WANT_WRITE:
+                                       conn->buf_events = POLLOUT;
+                                       break;
+                               default:
+                                       errno = EIO;
+                                       fetch_syserr();
+                                       return -1;
+                               }
+                       } else {
+                               /* Assume buffering on the SSL layer. */
+                               conn->buf_events = 0;
+                       }
+               } else
 #endif
                        rlen = read(conn->sd, buf, len);
                if (rlen >= 0)

Index: pkgsrc/net/libfetch/files/common.h
diff -u pkgsrc/net/libfetch/files/common.h:1.23 pkgsrc/net/libfetch/files/common.h:1.24
--- pkgsrc/net/libfetch/files/common.h:1.23     Wed Jan  8 20:25:34 2014
+++ pkgsrc/net/libfetch/files/common.h  Thu Oct 20 21:25:57 2016
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.h,v 1.23 2014/01/08 20:25:34 joerg Exp $        */
+/*     $NetBSD: common.h,v 1.24 2016/10/20 21:25:57 joerg Exp $        */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Co�dan Sm�rgrav
  * All rights reserved.
@@ -66,6 +66,7 @@ struct fetchconn {
        char            *buf;           /* buffer */
        size_t           bufsize;       /* buffer size */
        size_t           buflen;        /* length of buffer contents */
+       int              buf_events;    /* poll flags for the next cycle */
        char            *next_buf;      /* pending buffer, e.g. after getln */
        size_t           next_len;      /* size of pending buffer */
        int              err;           /* last protocol reply code */



Home | Main Index | Thread Index | Old Index