]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: raise known errors before checking for signals in waiting
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 26 Dec 2022 03:47:42 +0000 (03:47 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 29 Dec 2022 04:21:34 +0000 (04:21 +0000)
psycopg_c/psycopg_c/_psycopg/waiting.pyx

index c778c36e9adf8b013adac2b868694215a6919095..baaead63ccf75f4391dc44a30fcb4fe96587bc7b 100644 (file)
@@ -72,12 +72,9 @@ wait_c_impl(int fileno, int wait, float timeout)
     select_rv = poll(&input_fd, 1, timeout_ms);
     Py_END_ALLOW_THREADS
 
+    if (select_rv < 0) { goto error; }
     if (PyErr_CheckSignals()) { goto finally; }
 
-    if (select_rv < 0) {
-        goto error;
-    }
-
     if (input_fd.events & POLLIN) { rv |= SELECT_EV_READ; }
     if (input_fd.events & POLLOUT) { rv |= SELECT_EV_WRITE; }
 
@@ -120,12 +117,9 @@ wait_c_impl(int fileno, int wait, float timeout)
     select_rv = select(fileno + 1, &ifds, &ofds, &efds, tvptr);
     Py_END_ALLOW_THREADS
 
+    if (select_rv < 0) { goto error; }
     if (PyErr_CheckSignals()) { goto finally; }
 
-    if (select_rv < 0) {
-        goto error;
-    }
-
     if (FD_ISSET(fileno, &ifds)) { rv |= SELECT_EV_READ; }
     if (FD_ISSET(fileno, &ofds)) { rv |= SELECT_EV_WRITE; }