From: Brian Warner Date: Fri, 6 Aug 2010 07:07:05 +0000 (-0700) Subject: downloader.Segmentation: unregisterProducer when asked to stopProducing, this X-Git-Tag: allmydata-tahoe-1.8.0rc1~2 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/COPYING.TGPPL.html?a=commitdiff_plain;h=4b7c94ece074ede23b4b4a7b485fa3d984b81fec;p=tahoe-lafs%2Ftahoe-lafs.git downloader.Segmentation: unregisterProducer when asked to stopProducing, this seems to avoid the #1155 log message which reveals the URI (and filecap). Also add an [ERROR] marker to the flog entry, since unregisterProducer also makes interrupted downloads appear "200 OK"; this makes it more obvious that the download did not complete. --- diff --git a/src/allmydata/immutable/downloader/segmentation.py b/src/allmydata/immutable/downloader/segmentation.py index 4890195c..7c9f5cf6 100644 --- a/src/allmydata/immutable/downloader/segmentation.py +++ b/src/allmydata/immutable/downloader/segmentation.py @@ -36,10 +36,15 @@ class Segmentation: def start(self): self._alive = True self._deferred = defer.Deferred() + self._deferred.addBoth(self._done) self._consumer.registerProducer(self, True) self._maybe_fetch_next() return self._deferred + def _done(self, res): + self._consumer.unregisterProducer() + return res + def _maybe_fetch_next(self): if not self._alive or not self._hungry: return @@ -52,7 +57,6 @@ class Segmentation: # done! self._alive = False self._hungry = False - self._consumer.unregisterProducer() self._deferred.callback(self._consumer) return n = self._node @@ -135,10 +139,11 @@ class Segmentation: level=log.WEIRD, parent=self._lp, umid="EYlXBg") self._alive = False self._hungry = False - self._consumer.unregisterProducer() self._deferred.errback(f) def stopProducing(self): + log.msg("asked to stopProducing", + level=log.NOISY, parent=self._lp, umid="XIyL9w") self._hungry = False self._alive = False # cancel any outstanding segment request diff --git a/src/allmydata/web/filenode.py b/src/allmydata/web/filenode.py index a19059bc..e872e1e0 100644 --- a/src/allmydata/web/filenode.py +++ b/src/allmydata/web/filenode.py @@ -38,7 +38,7 @@ class ReplaceMeMixin: overwrite=replace) def _done(filenode): log.msg("webish upload complete", - facility="tahoe.webish", level=log.NOISY) + facility="tahoe.webish", level=log.NOISY, umid="TCjBGQ") if self.node: # we've replaced an existing file (or modified a mutable # file), so the response code is 200 @@ -446,6 +446,9 @@ class FileDownloader(rend.Page): return "" d = self.filenode.read(req, first, size) def _error(f): + log.msg("error during GET", facility="tahoe.webish", failure=f, + level=log.UNUSUAL, umid="xSiF3w") + req._tahoe_request_had_error = f # for HTTP-style logging if req.startedWriting: # The content-type is already set, and the response code has # already been sent, so we can't provide a clean error diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 8442bb25..2cd77aa7 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -18,6 +18,8 @@ from allmydata.web.common import IOpHandleTable, MyExceptionHandler parse_qs = http.parse_qs class MyRequest(appserver.NevowRequest): fields = None + _tahoe_request_had_error = None + def requestReceived(self, command, path, version): """Called by channel when all data has been received. @@ -107,12 +109,17 @@ class MyRequest(appserver.NevowRequest): uri = path + queryargs - log.msg(format="web: %(clientip)s %(method)s %(uri)s %(code)s %(length)s", + error = "" + if self._tahoe_request_had_error: + error = " [ERROR]" + + log.msg(format="web: %(clientip)s %(method)s %(uri)s %(code)s %(length)s%(error)s", clientip=self.getClientIP(), method=self.method, uri=uri, code=self.code, length=(self.sentLength or "-"), + error=error, facility="tahoe.webish", level=log.OPERATIONAL, )