mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-09 03:44:23 +00:00
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.
This commit is contained in:
parent
7fae62faf2
commit
4b7c94ece0
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user