mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
gh-123476: Add support for TCP_QUICKACK socket setting to Windows (#123478)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Steve Dower <steve.dower@microsoft.com>
This commit is contained in:
parent
6e43928831
commit
b5aa271f86
5 changed files with 59 additions and 5 deletions
|
@ -3166,6 +3166,17 @@ sock_setsockopt(PySocketSockObject *s, PyObject *args)
|
|||
/* setsockopt(level, opt, flag) */
|
||||
if (PyArg_ParseTuple(args, "iii:setsockopt",
|
||||
&level, &optname, &flag)) {
|
||||
#ifdef MS_WINDOWS
|
||||
if (optname == SIO_TCP_SET_ACK_FREQUENCY) {
|
||||
int dummy;
|
||||
res = WSAIoctl(s->sock_fd, SIO_TCP_SET_ACK_FREQUENCY, &flag,
|
||||
sizeof(flag), NULL, 0, &dummy, NULL, NULL);
|
||||
if (res >= 0) {
|
||||
s->quickack = flag;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
res = setsockopt(s->sock_fd, level, optname,
|
||||
(char*)&flag, sizeof flag);
|
||||
goto done;
|
||||
|
@ -3251,6 +3262,11 @@ sock_getsockopt(PySocketSockObject *s, PyObject *args)
|
|||
return s->errorhandler();
|
||||
return PyLong_FromUnsignedLong(vflag);
|
||||
}
|
||||
#endif
|
||||
#ifdef MS_WINDOWS
|
||||
if (optname == SIO_TCP_SET_ACK_FREQUENCY) {
|
||||
return PyLong_FromLong(s->quickack);
|
||||
}
|
||||
#endif
|
||||
flagsize = sizeof flag;
|
||||
res = getsockopt(s->sock_fd, level, optname,
|
||||
|
@ -5316,6 +5332,9 @@ sock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
((PySocketSockObject *)new)->sock_fd = INVALID_SOCKET;
|
||||
((PySocketSockObject *)new)->sock_timeout = _PyTime_FromSeconds(-1);
|
||||
((PySocketSockObject *)new)->errorhandler = &set_error;
|
||||
#ifdef MS_WINDOWS
|
||||
((PySocketSockObject *)new)->quickack = 0;
|
||||
#endif
|
||||
}
|
||||
return new;
|
||||
}
|
||||
|
@ -8616,6 +8635,9 @@ socket_exec(PyObject *m)
|
|||
#ifdef TCP_CONNECTION_INFO
|
||||
ADD_INT_MACRO(m, TCP_CONNECTION_INFO);
|
||||
#endif
|
||||
#ifdef SIO_TCP_SET_ACK_FREQUENCY
|
||||
#define TCP_QUICKACK SIO_TCP_SET_ACK_FREQUENCY
|
||||
#endif
|
||||
#ifdef TCP_QUICKACK
|
||||
ADD_INT_MACRO(m, TCP_QUICKACK);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue