chiark / gitweb /
no dupe warning on cancel
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 2 Apr 2017 03:13:41 +0000 (04:13 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 2 Apr 2017 03:13:41 +0000 (04:13 +0100)
server

diff --git a/server b/server
index 3781d56..9c61b7b 100755 (executable)
--- a/server
+++ b/server
@@ -90,10 +90,17 @@ class Client():
     self._pq.append(packet)
     self._check_outbound()
 
+  def _req_fin(self, dummy, request, cl):
+    self._log(DBG.HTTP_CTRL, '_req_fin ' + repr(dummy), idof=request)
+    try: cl.cancel()
+    except twisted.internet.error.AlreadyCalled: pass
+
   def new_request(self, request):
     request.setHeader('Content-Type','application/octet-stream')
-    reactor.callLater(self.http_timeout, self._req_cancel, request)
-    request.notifyFinish().addErrback(self._req_error, request)
+    cl = reactor.callLater(self.http_timeout, self._req_cancel, request)
+    nf = request.notifyFinish()
+    nf.addErrback(self._req_error, request)
+    nf.addCallback(self._req_fin, request, cl)
     self._rq.append(request)
     self._check_outbound()