Commit d467756c authored by Antoine Millet's avatar Antoine Millet
Browse files

Fixed buf with SSL sockets in writer

parent 9834ca91
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -107,6 +107,11 @@ class RpcConnection(object):
                                                fd=self._sock,
                                                events=pyev.EV_WRITE,
                                                callback=self._writer)
        # OpenSSL requires that the SAME string object must be used on the
        # next send retry when all the entire buffer can't be write on the
        # socket. This attribute store this string, or None if the previous
        # send has been a success:
        self._writer_last_try_buf = None

        # Is the RpcConnection connected to its peer:
        self._connected = True
@@ -291,17 +296,20 @@ class RpcConnection(object):
                if self.fallback:
                    sent = self._sock.send(self._outbound_buffer[:4096])
                else:
                    sent = self._sock.send(self._outbound_buffer)
                    if self._writer_last_try_buf is None:
                        self._writer_last_try_buf = self._outbound_buffer[:1024 * 128]
                    sent = self._sock.send(self._writer_last_try_buf)
            except socket.error as err:
                if (isinstance(err, socket.error) and err.errno
                    in RpcConnection.NONBLOCKING_ERRORS):
                if (isinstance(err, socket.error) and err.errno in RpcConnection.NONBLOCKING_ERRORS):
                    return
                elif (isinstance(err, ssl.SSLError) and err.errno
                    in RpcConnection.NONBLOCKING_SSL_ERRORS):
                elif (isinstance(err, ssl.SSLError) and err.errno in RpcConnection.NONBLOCKING_SSL_ERRORS):
                    return
                errmsg = 'Fatal error while sending through socket: %s' % err
                self.logger.error(errmsg)
                raise SocketError(errmsg)
                self.shutdown()
                return
            else:
                self._writer_last_try_buf = None
            self._outbound_buffer = self._outbound_buffer[sent:]

        if not self._outbound_buffer: