]> granicus.if.org Git - postgresql/commitdiff
Use OpenSSL's SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 24 Jul 2011 19:18:12 +0000 (15:18 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 24 Jul 2011 19:18:12 +0000 (15:18 -0400)
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.

src/backend/libpq/be-secure.c
src/interfaces/libpq/fe-secure.c

index f595e8f42404181500b73ef9d7f27cb2c60d931f..64efac001b1ac55b26535f853b3f765af4413cd3 100644 (file)
@@ -727,6 +727,12 @@ initialize_SSL(void)
                                        (errmsg("could not create SSL context: %s",
                                                        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
                 */
index 9c4f636d3e73d1cc688a41509f6ede48e52afd38..769a36a0606ec29a03f875f138134495bd500af4 100644 (file)
@@ -900,6 +900,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
        pthread_mutex_unlock(&init_mutex);