]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
SFTP: avoid race condition where .write could be called on an OverwriteableFileConsum...
authordavid-sarah <david-sarah@jacaranda.org>
Sun, 23 May 2010 23:38:30 +0000 (16:38 -0700)
committerdavid-sarah <david-sarah@jacaranda.org>
Sun, 23 May 2010 23:38:30 +0000 (16:38 -0700)
src/allmydata/frontends/sftpd.py

index d1265de64669f36d3db1fdb48f84d25fbc98b107..819191a87c4124e2b77d16ca19b0ca81b506d221 100644 (file)
@@ -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(<data of length %r>)" % (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()