aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-12-01 17:43:14 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-12-01 17:45:04 +0200
commit4e86f1b16da85ba0a99c592dc7b977b3be80a483 (patch)
tree38f0c162189df4ab209b3832f6215d8c2b9725c1 /src
parent6d6cade05bcb68ca8677aa5502ca73274d6e4539 (diff)
downloadpostgresql-4e86f1b16da85ba0a99c592dc7b977b3be80a483.tar.gz
postgresql-4e86f1b16da85ba0a99c592dc7b977b3be80a483.zip
Put SSL_pending() call behind the new internal SSL API.
It seems likely that any SSL implementation will need a similar call, not just OpenSSL.
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/libpq/fe-misc.c4
-rw-r--r--src/interfaces/libpq/fe-secure-openssl.c9
-rw-r--r--src/interfaces/libpq/libpq-int.h1
3 files changed, 12 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index f58d7987423..de0f9efd275 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -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;
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 78aa46de2f3..7fcc1f02f85 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -187,6 +187,15 @@ pgtls_open_client(PGconn *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.
*
* On failure, this function is responsible for putting a suitable message
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 4ef46fff47d..c3455718b69 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -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);
/*