commit:     dc7faa37c3b5b9cbb9736d4b1669510db1b953d6
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 16 06:40:16 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Apr 16 06:40:16 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=dc7faa37

EventLoop: fix add_reader/writer to call source_remove

The previous instance of self._selector_callback has to be removed
before replacing it with a new instance.

Fixes: 2b6e90fadfb1 ("EventLoop: support add_reader/writer fd overlap (bug 
649588)")

 pym/portage/util/_eventloop/EventLoop.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pym/portage/util/_eventloop/EventLoop.py 
b/pym/portage/util/_eventloop/EventLoop.py
index 0024d162c..38e735999 100644
--- a/pym/portage/util/_eventloop/EventLoop.py
+++ b/pym/portage/util/_eventloop/EventLoop.py
@@ -620,6 +620,7 @@ class EventLoop(object):
                                if mask != self._EVENT_READ:
                                        selector_mask |= mask
                                        callbacks.append(item)
+                       self.source_remove(handler.source_id)
                self.io_add_watch(fd, selector_mask, 
self._selector_callback(callbacks))
 
        def remove_reader(self, fd):
@@ -667,6 +668,7 @@ class EventLoop(object):
                                if mask != self._EVENT_WRITE:
                                        selector_mask |= mask
                                        callbacks.append(item)
+                       self.source_remove(handler.source_id)
                self.io_add_watch(fd, selector_mask, 
self._selector_callback(callbacks))
 
        def remove_writer(self, fd):

Reply via email to