daemon: record the deferred for a request in the queue, too
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 24 Apr 2017 00:36:35 +0000 (01:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 24 Apr 2017 00:36:39 +0000 (01:36 +0100)
So we can check nf.called, rather than request.finished.  The latter
can be false even after the request has failed and is unfinishable.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
hippotatd

index 0482876..40f4c69 100755 (executable)
--- a/hippotatd
+++ b/hippotatd
@@ -126,7 +126,7 @@ class Client():
     nf = request.notifyFinish()
     nf.addErrback(self._req_error, request)
     nf.addCallback(self._req_fin, request, cl)
-    self._rq.append(request)
+    self._rq.append((request,nf))
     self._check_outbound()
 
   def _req_write(self, req, d):
@@ -136,9 +136,9 @@ class Client():
   def _check_outbound(self):
     log_debug(DBG.HTTP_CTRL, 'CHKO')
     while True:
-      try: request = self._rq[0]
+      try: (request,nf) = self._rq[0]
       except IndexError: request = None
-      if request and request.finished:
+      if request and nf.called:
         self._log(DBG.HTTP_CTRL, 'CHKO req finished, discard', idof=request)
         self._rq.popleft()
         continue
@@ -166,7 +166,7 @@ class Client():
       # round again, looking for more to do
 
     while len(self._rq) > self.cc.target_requests_outstanding:
-      request = self._rq.popleft()
+      (request, nf) = self._rq.popleft()
       self._log(DBG.HTTP, 'CHKO above target, returning empty', idof=request)
       request.finish()