]> granicus.if.org Git - postgresql/commitdiff
Put SSL_pending() call behind the new internal SSL API.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 1 Dec 2014 15:43:14 +0000 (17:43 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 1 Dec 2014 15:45:04 +0000 (17:45 +0200)
It seems likely that any SSL implementation will need a similar call, not
just OpenSSL.

src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/fe-secure-openssl.c
src/interfaces/libpq/libpq-int.h

index f58d7987423bc9336030e00bce4ba4660686bf1a..de0f9efd275ba0dddb2e9eb52b16aa1b92dceadc 100644 (file)
@@ -1054,9 +1054,9 @@ pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time)
                return -1;
        }
 
-#ifdef USE_OPENSSL
+#ifdef USE_SSL
        /* Check for SSL library buffering read bytes */
-       if (forRead && conn->ssl && SSL_pending(conn->ssl) > 0)
+       if (forRead && conn->ssl_in_use && pgtls_read_pending(conn) > 0)
        {
                /* short-circuit the select */
                return 1;
index 78aa46de2f3d5c4404ec4dcbf632c8fb74afba63..7fcc1f02f85f2ec9067bdc570e538ab221e8bf78 100644 (file)
@@ -186,6 +186,15 @@ pgtls_open_client(PGconn *conn)
        return open_client_SSL(conn);
 }
 
+/*
+ *  Is there unread data waiting in the SSL read buffer?
+ */
+bool
+pgtls_read_pending(PGconn *conn)
+{
+       return SSL_pending(conn->ssl);
+}
+
 /*
  *     Read data from a secure connection.
  *
index 4ef46fff47dfe591dae3adbe548078e5c07c8fbd..c3455718b693761e0627017c490a0d5e1b004076 100644 (file)
@@ -641,6 +641,7 @@ extern int pgtls_init(PGconn *conn);
 extern PostgresPollingStatusType pgtls_open_client(PGconn *conn);
 extern void pgtls_close(PGconn *conn);
 extern ssize_t pgtls_read(PGconn *conn, void *ptr, size_t len);
+extern bool pgtls_read_pending(PGconn *conn);
 extern ssize_t pgtls_write(PGconn *conn, const void *ptr, size_t len);
 
 /*