Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use a fresh timeval variable for select(2) portability
  • Loading branch information
picnixz committed Dec 27, 2024
commit 2996937efc492804110a0bc8ab57f3a9bf6e35f6
12 changes: 10 additions & 2 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2407,15 +2407,23 @@ pysleep(PyTime_t timeout)
static int
pysleep_zero_posix(void)
Comment thread
picnixz marked this conversation as resolved.
Outdated
{
static struct timeval zero = {0, 0};

PyTime_t deadline, monotonic;
if (PyTime_Monotonic(&monotonic) < 0) {
return -1;
}
deadline = monotonic;
do {
int ret, err;
// POSIX-compliant select(2) allows the 'timeout' parameter to
// be modified but also mandates that the function should return
// immediately if *both* structure's fields are zero (which is
// the case here).
//
// However, since System V (but not BSD) variant typically sets
// the timeout before returning (but does not specify whether
// this is also the case for zero timeouts), we prefer supplying
// a fresh timeout everytime.
struct timeval zero = {0, 0};
Py_BEGIN_ALLOW_THREADS
ret = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &zero);
Comment thread
picnixz marked this conversation as resolved.
Outdated
err = errno;
Comment thread
picnixz marked this conversation as resolved.
Outdated
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ Modules/pyexpat.c - error_info_of -
Modules/pyexpat.c - handler_info -
Modules/termios.c - termios_constants -
Modules/timemodule.c init_timezone YEAR -
Modules/timemodule.c pysleep_zero_posix zero -
Objects/bytearrayobject.c - _PyByteArray_empty_string -
Objects/complexobject.c - c_1 -
Objects/exceptions.c - static_exceptions -
Expand Down