Author cbay
Recipients cbay
Date 2010-03-26.15:30:32
SpamBayes Score 7.58212e-08
Marked as misclassified No
Message-id <1269617434.76.0.650979265578.issue8240@psf.upfronthosting.co.za>
In-reply-to
Content
ssl.SSLSocket.write on non-blocking sockets will fail with:

_ssl.c:1217: error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry

on a write retry, if the buffer address has changed between the initial call and the retry (when the initial call returned 0 bytes written, which means you should try again later).

From OpenSSL docs (http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html):

SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
Make it possible to retry SSL_write() with changed buffer location (the buffer contents must stay the same). This is not the default to avoid the misconception that non-blocking SSL_write() behaves like non-blocking write().

Attached patch fixes the problem (tested on Python 2.6.5, 2.7 trunk) by calling SSL_CTX_set_mode with SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER. It's a single line patch.
History
Date User Action Args
2010-03-26 15:30:34cbaysetrecipients: + cbay
2010-03-26 15:30:34cbaysetmessageid: <1269617434.76.0.650979265578.issue8240@psf.upfronthosting.co.za>
2010-03-26 15:30:33cbaylinkissue8240 messages
2010-03-26 15:30:33cbaycreate