From 969a1fca85d025005604f4da892da678488c8835 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 24 Apr 2017 01:36:35 +0100 Subject: [PATCH] daemon: record the deferred for a request in the queue, too 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 --- hippotatd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hippotatd b/hippotatd index 0482876..40f4c69 100755 --- 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() -- 2.11.0