aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-07-24 15:18:07 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-07-24 15:18:07 -0400
commit383c7ce42b22afa7f2f6b144e81783dbe8653b45 (patch)
tree25552f8312946263e2cc247562ae9572ebffe794 /src
parente06d1a88f3003bbff96ba052e5ba2366265db623 (diff)
downloadpostgresql-383c7ce42b22afa7f2f6b144e81783dbe8653b45.tar.gz
postgresql-383c7ce42b22afa7f2f6b144e81783dbe8653b45.zip
Use OpenSSL's SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This disables an entirely unnecessary "sanity check" that causes failures in nonblocking mode, because OpenSSL complains if we move or compact the write buffer. The only actual requirement is that we not modify pending data once we've attempted to send it, which we don't. Per testing and research by Martin Pihlak, though this fix is a lot simpler than his patch. I put the same change into the backend, although it's less clear whether it's necessary there. We do use nonblock mode in some situations in streaming replication, so seems best to keep the same behavior in the backend as in libpq. Back-patch to all supported releases.
Diffstat (limited to 'src')
-rw-r--r--src/backend/libpq/be-secure.c6
-rw-r--r--src/interfaces/libpq/fe-secure.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c
index 6f38b2c7292..3f4c15dd259 100644
--- a/src/backend/libpq/be-secure.c
+++ b/src/backend/libpq/be-secure.c
@@ -730,6 +730,12 @@ initialize_SSL(void)
SSLerrmessage())));
/*
+ * Disable OpenSSL's moving-write-buffer sanity check, because it
+ * causes unnecessary failures in nonblocking send cases.
+ */
+ SSL_CTX_set_mode(SSL_context, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
+
+ /*
* Load and verify certificate and private key
*/
if (SSL_CTX_use_certificate_chain_file(SSL_context,
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index e7cd2a4561e..422ef1f1090 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -947,6 +947,12 @@ init_ssl_system(PGconn *conn)
#endif
return -1;
}
+
+ /*
+ * Disable OpenSSL's moving-write-buffer sanity check, because it
+ * causes unnecessary failures in nonblocking send cases.
+ */
+ SSL_CTX_set_mode(SSL_context, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
}
#ifdef ENABLE_THREAD_SAFETY