Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c24ca4b

Browse files
committed
Fix probable bug; if errno == EINTR, floatsleep() doesn't break out of
a Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS block, but it calls Py_BLOCK_THREADS anyway. The change moves Py_BLOCK_THREADS to inside the if, so it's only executed when the function actually returns unexpectedly.
1 parent 70b5d47 commit c24ca4b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/timemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,12 +755,12 @@ floatsleep(double secs)
755755
t.tv_usec = (long)(frac*1000000.0);
756756
Py_BEGIN_ALLOW_THREADS
757757
if (select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t) != 0) {
758-
Py_BLOCK_THREADS
759758
#ifdef EINTR
760759
if (errno != EINTR) {
761760
#else
762761
if (1) {
763762
#endif
763+
Py_BLOCK_THREADS
764764
PyErr_SetFromErrno(PyExc_IOError);
765765
return -1;
766766
}

0 commit comments

Comments
 (0)