]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Fix wait_epoll() when the fd is read- and write-ready
authorDenis Laxalde <denis@laxalde.org>
Sun, 17 Oct 2021 18:59:58 +0000 (20:59 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 16 Nov 2021 10:28:18 +0000 (11:28 +0100)
We follow the implementation of EpollSelector.select(). The
test_wait_ready() introduced previously added now passes for
wait_epoll().

psycopg/psycopg/waiting.py

index 2c2f75bc934ee41abb657c0ed2fc725d627b1e2a..59bbd6559bc409fdd1aa2332f08492fc582cf7da 100644 (file)
@@ -232,11 +232,12 @@ def wait_epoll(
             while not fileevs:
                 fileevs = epoll.poll(timeout)
             ev = fileevs[0][1]
+            ready = 0
             if ev & ~select.EPOLLOUT:
-                s = Ready.R
-            else:
-                = Ready.W
-            s = gen.send(s)
+                ready = Ready.R
+            if ev & ~select.EPOLLIN:
+                ready |= Ready.W
+            s = gen.send(ready)
             evmask = poll_evmasks[s]
             epoll.modify(fileno, evmask)