mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #23834: Fix initial value of the socket timeout
Use _PyTime_FromSeconds() to initialize the default socket timeout to -1 second, instead of -1 nanosecond which causes rounding issues in internal_select().
This commit is contained in:
parent
62aa7dc7c9
commit
9001d8089c
1 changed files with 2 additions and 2 deletions
|
@ -2292,7 +2292,7 @@ sock_setblocking(PySocketSockObject *s, PyObject *arg)
|
||||||
if (block == -1 && PyErr_Occurred())
|
if (block == -1 && PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
s->sock_timeout = block ? -1 : 0;
|
s->sock_timeout = _PyTime_FromSeconds(block ? -1 : 0);
|
||||||
internal_setblocking(s, block);
|
internal_setblocking(s, block);
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
@ -4162,7 +4162,7 @@ sock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
new = type->tp_alloc(type, 0);
|
new = type->tp_alloc(type, 0);
|
||||||
if (new != NULL) {
|
if (new != NULL) {
|
||||||
((PySocketSockObject *)new)->sock_fd = -1;
|
((PySocketSockObject *)new)->sock_fd = -1;
|
||||||
((PySocketSockObject *)new)->sock_timeout = -1;
|
((PySocketSockObject *)new)->sock_timeout = _PyTime_FromSeconds(-1);
|
||||||
((PySocketSockObject *)new)->errorhandler = &set_error;
|
((PySocketSockObject *)new)->errorhandler = &set_error;
|
||||||
}
|
}
|
||||||
return new;
|
return new;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue