-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-123476: Add support for existing TCP_QUICKACK socket setting to Windows #123478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 33 commits
c030ee4
8d510a2
635e385
ac49caf
183a18e
e96d9db
8147664
02ffa52
4f92750
1ca08b7
a0889a5
f2e8cca
a607fec
016a2c6
d06cbe7
ce8c1ab
5c887b6
8185776
7616b21
4b49a2e
94f9087
ebd8a9d
a478e5e
776d231
23c5522
d0527e3
9ad2430
fe453bc
ec053ad
8c06855
d7cb426
1bc9b7a
9cadf5b
e9a39b6
4b0f5db
559bbcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for ``socket.TCP_QUICKACK`` on Windows platforms. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I understand that this constant cannot be used by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, on windows platform, QUICKACK can only be set through WSAIoctl() and is not supported through setsockopt() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another quick note to help with review: On Windows, the only values accepted for SIO_TCP_SET_ACK_FREQUENCY is 0 and 1, with 1 meaning "ack every 1 packets" aka TCP_QUICKACK is on, and 0 meaning "use default value" aka TCP_QUICKACK is off. So there's no need to translate the value set by the user. 1 is on, 0 is off, just like TCP_NODELAY and other socket flags. A convenient coincidence. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I un-resolved this conversation so that future reviewers can see it (otherwise GH hides it). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll throw another note in here for future reviewers then: there is no equivalent SIO_TCP_GET_ACK_FREQUENCY, so the value must be saved in the socket object. On Windows SIO_TCP_SET_ACK_FREQUENCY is always 0 for a new socket, and the socket->quickack variable is always initialized to 0, so the response value from socket.getsockopt for TCP_QUICKACK will always be correct on Windows even if not previously set. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another explanation of behavior for future reviewers, please see this comment: #123478 (comment) |
||
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 | ||
nkinnan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
nkinnan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif | ||
#ifdef TCP_QUICKACK | ||
ADD_INT_MACRO(m, TCP_QUICKACK); | ||
#endif | ||
|
Uh oh!
There was an error while loading. Please reload this page.