Author: arigo <[email protected]>
Branch: 
Changeset: r65392:a1903b9725c4
Date: 2013-07-15 10:32 +0200
http://bitbucket.org/pypy/pypy/changeset/a1903b9725c4/

Log:    Merged in bdarnell/pypy/ssl_moving_write_buffer (pull request #160)

        Add the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag. This is the same
        code as http://hg.python.org/cpython/rev/60310223d075 .

diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -722,7 +722,10 @@
     libssl_SSL_CTX_set_verify(ss.ctx, verification_mode, None)
     ss.ssl = libssl_SSL_new(ss.ctx) # new ssl struct
     libssl_SSL_set_fd(ss.ssl, sock_fd) # set the socket for SSL
-    libssl_SSL_set_mode(ss.ssl, SSL_MODE_AUTO_RETRY)
+    # The ACCEPT_MOVING_WRITE_BUFFER flag is necessary because the address
+    # of a str object may be changed by the garbage collector.
+    libssl_SSL_set_mode(ss.ssl, 
+                        SSL_MODE_AUTO_RETRY | 
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)
 
     # If the socket is in non-blocking mode or timeout mode, set the BIO
     # to non-blocking mode (blocking is the default)
diff --git a/rpython/rlib/ropenssl.py b/rpython/rlib/ropenssl.py
--- a/rpython/rlib/ropenssl.py
+++ b/rpython/rlib/ropenssl.py
@@ -93,6 +93,7 @@
     SSL_RECEIVED_SHUTDOWN = rffi_platform.ConstantInteger(
         "SSL_RECEIVED_SHUTDOWN")
     SSL_MODE_AUTO_RETRY = rffi_platform.ConstantInteger("SSL_MODE_AUTO_RETRY")
+    SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = 
rffi_platform.ConstantInteger("SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER")
 
     NID_subject_alt_name = 
rffi_platform.ConstantInteger("NID_subject_alt_name")
     GEN_DIRNAME = rffi_platform.ConstantInteger("GEN_DIRNAME")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to