From 05f1c780982058482148bb8a4d07215d0293f4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 15 Feb 2019 14:58:56 +0100 Subject: [PATCH] XTLS: Fix endless loop on write error --- gajim/common/socks5.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gajim/common/socks5.py b/gajim/common/socks5.py index a37ce0e27..9cea47389 100644 --- a/gajim/common/socks5.py +++ b/gajim/common/socks5.py @@ -687,13 +687,11 @@ class Socks5: OpenSSL.SSL.WantX509LookupError) as e: log.info('SSL rehandshake request: %s', repr(e)) raise e + except OpenSSL.SSL.SysCallError: + return self._on_send_exception() except Exception as e: if e.errno not in (EINTR, ENOBUFS, EWOULDBLOCK): - # peer stopped reading - self.state = 8 # end connection - self.disconnect() - self.file_props.error = -1 - return -1 + return self._on_send_exception() self.size += lenn current_time = time.time() self.file_props.elapsed_time += current_time - \ @@ -719,6 +717,13 @@ class Socks5: self.disconnect() return -1 + def _on_send_exception(self): + # peer stopped reading + self.state = 8 # end connection + self.disconnect() + self.file_props.error = -1 + return -1 + def get_file_contents(self, timeout): """ Read file contents from socket and write them to file