diff --git a/src/allmydata/immutable/downloader/fetcher.py b/src/allmydata/immutable/downloader/fetcher.py index 4e8b7f926..130bb93dc 100644 --- a/src/allmydata/immutable/downloader/fetcher.py +++ b/src/allmydata/immutable/downloader/fetcher.py @@ -63,13 +63,14 @@ class SegmentFetcher(object): self._running = True def stop(self): - log.msg("SegmentFetcher(%r).stop" % self._node._si_prefix, - level=log.NOISY, parent=self._lp, umid="LWyqpg") - self._cancel_all_requests() - self._running = False - # help GC ??? XXX - del self._shares, self._shares_from_server, self._active_share_map - del self._share_observers + if self._running: + log.msg("SegmentFetcher(%r).stop" % self._node._si_prefix, + level=log.NOISY, parent=self._lp, umid="LWyqpg") + self._cancel_all_requests() + self._running = False + # help GC ??? + del self._shares, self._shares_from_server, self._active_share_map + del self._share_observers # called by our parent _Node diff --git a/src/allmydata/immutable/downloader/node.py b/src/allmydata/immutable/downloader/node.py index a58d82a01..102d29a0a 100644 --- a/src/allmydata/immutable/downloader/node.py +++ b/src/allmydata/immutable/downloader/node.py @@ -533,10 +533,11 @@ class DownloadNode(object): self._segment_requests = [t for t in self._segment_requests if t[2] != cancel] segnums = [segnum for (segnum,d,c,seg_ev,lp) in self._segment_requests] + # self._active_segment might be None in rare circumstances, so make # sure we tolerate it if self._active_segment and self._active_segment.segnum not in segnums: - seg, self._active_segment = self._active_segment, None##True # XXX None for real + seg, self._active_segment = self._active_segment, None seg.stop() self._start_new_segment()