From fc3507c1f646ae2f580b9b0cc40f77f9507986b3 Mon Sep 17 00:00:00 2001 From: meejah Date: Fri, 2 Apr 2021 23:36:33 -0600 Subject: [PATCH] flip around 'if' logic to simplify --- src/wormhole_transit_relay/transit_server.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wormhole_transit_relay/transit_server.py b/src/wormhole_transit_relay/transit_server.py index 91d84e0..426f50f 100644 --- a/src/wormhole_transit_relay/transit_server.py +++ b/src/wormhole_transit_relay/transit_server.py @@ -84,16 +84,16 @@ class TransitConnection(LineReceiver): # point the sender will only transmit data as fast as the # receiver can handle it. if self._sent_ok: - if not self._buddy: - # Our buddy disconnected (we're "jilted"), so we hung up too, - # but our incoming data hasn't stopped yet (it will in a - # moment, after our disconnect makes a roundtrip through the - # kernel). This probably means the file receiver hung up, and - # this connection is the file sender. In may-2020 this - # happened 11 times in 40 days. - return - self._total_sent += len(data) - self._buddy.transport.write(data) + # if self._buddy is None then our buddy disconnected + # (we're "jilted"), so we hung up too, but our incoming + # data hasn't stopped yet (it will in a moment, after our + # disconnect makes a roundtrip through the kernel). This + # probably means the file receiver hung up, and this + # connection is the file sender. In may-2020 this happened + # 11 times in 40 days. + if self._buddy: + self._total_sent += len(data) + self._buddy.transport.write(data) return # handshake is complete but not yet sent_ok