[New-bugs-announce] [issue3890] ssl.SSLSocket.recv() implementation may not work with non-blocking sockets

Giampaolo Rodola' report at bugs.python.org
Wed Sep 17 22:35:52 CEST 2008


New submission from Giampaolo Rodola' <billiejoex at users.sourceforge.net>:

As discussed on the python-dev ml I noticed something in the ssl.py code
which seems to be wrong. This is the ssl.SSLSocket.recv() method:

    def recv (self, buflen=1024, flags=0): 
        if self._sslobj: 
            if flags != 0: 
                raise ValueError( 
                    "non-zero flags not allowed in calls to sendall() 
on %s" % 
                    self.__class__) 
            while True: 
                try: 
                    return self.read(buflen) 
                except SSLError, x: 
                    if x.args[0] == SSL_ERROR_WANT_READ: 
                        continue 
                    else: 
                        raise x 
        else: 
            return socket.recv(self, buflen, flags) 

I don't know the low levels but that while statement which continues 
in case of SSL_ERROR_WANT_READ seems to be wrong (blocking), at least 
when dealing with non-blocking sockets. I think the proper way of 
doing recv() here is letting SSL_ERROR_WANT_READ propagate and let the 
upper application (e.g. asyncore) deal with it.

----------
components: Library (Lib)
messages: 73342
nosy: giampaolo.rodola, janssen, josiah.carlson, josiahcarlson
severity: normal
status: open
title: ssl.SSLSocket.recv() implementation may not work with non-blocking sockets
type: behavior
versions: Python 2.6, Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3890>
_______________________________________


More information about the New-bugs-announce mailing list