flip around 'if' logic to simplify

This commit is contained in:
meejah 2021-04-02 23:36:33 -06:00
parent f3c391e98b
commit fc3507c1f6

View File

@ -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