From: david-sarah Date: Sun, 23 May 2010 23:38:30 +0000 (-0700) Subject: SFTP: avoid race condition where .write could be called on an OverwriteableFileConsum... X-Git-Tag: trac-4400~8 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/running.html?a=commitdiff_plain;h=6e114e44b543e29423f86408e5acdfbf7813c14e;p=tahoe-lafs%2Ftahoe-lafs.git SFTP: avoid race condition where .write could be called on an OverwriteableFileConsumer after it had been closed. --- diff --git a/src/allmydata/frontends/sftpd.py b/src/allmydata/frontends/sftpd.py index d1265de6..819191a8 100644 --- a/src/allmydata/frontends/sftpd.py +++ b/src/allmydata/frontends/sftpd.py @@ -336,6 +336,7 @@ class OverwriteableFileConsumer(PrefixingLogMixin): self.downloaded = 0 self.milestones = [] # empty heap of (offset, d) self.overwrites = [] # empty heap of (start, end) + self.is_closed = False self.done = self.when_reached(download_size) # adds a milestone self.is_done = False def _signal_done(ign): @@ -376,6 +377,8 @@ class OverwriteableFileConsumer(PrefixingLogMixin): def write(self, data): if noisy: self.log(".write()" % (len(data),), level=NOISY) + if self.is_closed: + return if self.check_abort(): self.close() return @@ -520,6 +523,7 @@ class OverwriteableFileConsumer(PrefixingLogMixin): #self.unregisterProducer() def close(self): + self.is_closed = True self.finish() self.f.close()