]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
downloader.Segmentation: unregisterProducer when asked to stopProducing, this
authorBrian Warner <warner@lothar.com>
Fri, 6 Aug 2010 07:07:05 +0000 (00:07 -0700)
committerBrian Warner <warner@lothar.com>
Fri, 6 Aug 2010 07:07:05 +0000 (00:07 -0700)
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.

src/allmydata/immutable/downloader/segmentation.py
src/allmydata/web/filenode.py
src/allmydata/webish.py

index 4890195c6cf39c66ae395bb57fb5e8a956792395..7c9f5cf65460ff6b7fe07b33dbce8dd492abf34c 100644 (file)
@@ -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
index a19059bcde8618f18dbb7f402a4598af2e112c3c..e872e1e0535609b3847e5b6a0d92d9c3f89bdb24 100644 (file)
@@ -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
index 8442bb25db4a42d75b13724339dd274ac3b93bd6..2cd77aa7c3851d98cfa5365aacc5879ae9e7e253 100644 (file)
@@ -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,
                 )