New submission from Cyril <c...@excellency.fr>:

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.

----------
components: Library (Lib)
files: _ssl.c.patch
keywords: patch
messages: 101753
nosy: cbay
severity: normal
status: open
title: ssl.SSLSocket.write may fail on non-blocking sockets
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file16668/_ssl.c.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8240>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to