summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-15 16:30:02 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-15 16:30:02 -0700
commit0562ac6f03894e1f9450b0ec426d6c4737de6488 (patch)
tree5d73b80ed6d06142bb6c914b9901d829e3b33298
parentd4101f5f57a2a2f7be7bac1e16954142ae8742f4 (diff)
downloadportage-0562ac6f03894e1f9450b0ec426d6c4737de6488.tar.gz
portage-0562ac6f03894e1f9450b0ec426d6c4737de6488.tar.bz2
portage-0562ac6f03894e1f9450b0ec426d6c4737de6488.zip
Fix PollScheduler._unregister() to discard any unhandled events
that belong to the unregistered file, in order to prevent these events from being erroneously delivered to a future handler that is using a reallocated file descriptor of the same numeric value (causing extremely confusing bugs). Note that this is was the cause of the intermittent bug that forced me to disable EbuildIpcDaemon by default.
-rw-r--r--pym/_emerge/PollScheduler.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py
index 52a33772b..738dcc7f1 100644
--- a/pym/_emerge/PollScheduler.py
+++ b/pym/_emerge/PollScheduler.py
@@ -192,6 +192,19 @@ class PollScheduler(object):
def _unregister(self, reg_id):
f = self._poll_event_handler_ids[reg_id]
self._poll_obj.unregister(f)
+ if self._poll_event_queue:
+ # Discard any unhandled events that belong to this file,
+ # in order to prevent these events from being erroneously
+ # delivered to a future handler that is using a reallocated
+ # file descriptor of the same numeric value (causing
+ # extremely confusing bugs).
+ remove = set()
+ for event in self._poll_event_queue:
+ if event[0] == f:
+ remove.add(event)
+ if remove:
+ self._poll_event_queue[:] = [event for event in \
+ self._poll_event_queue if event not in remove]
del self._poll_event_handlers[f]
del self._poll_event_handler_ids[reg_id]