From de8efdb9f95b5d62e9d09819d739da7dedf03c9c Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 26 Jun 2016 11:46:09 -0700 Subject: [PATCH] cmd_send: wait for ack from close() Without this, the sender drops the connection before the "close" message has made it to the server, which leaves the mailbox hanging until it expires. It still lives in a 'd.addBoth()' slot, so it gets closed even if some error occurrs, but we wait for it's Deferred to fire in both success and failure cases. --- src/wormhole/cli/cmd_send.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index cf082a9..5da9969 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -48,10 +48,9 @@ class Sender: w = wormhole(APPID, self._args.relay_url, self._reactor, self._tor_manager, timing=self._timing) - try: - yield self._go(w) - finally: - w.close() + d = self._go(w) + d.addBoth(w.close) # must wait for ack from close() + yield d def _send_data(self, data, w): data_bytes = dict_to_bytes(data)