-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-35589: Prevent buffer copy in sock_sendall() #11418
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Some tests are not required? |
There are tests for sending large data already. |
Lib/asyncio/selector_events.py
Outdated
|
||
fut = self.create_future() | ||
fd = sock.fileno() | ||
fut.add_done_callback( | ||
functools.partial(self._sock_write_done, fd)) | ||
self.add_writer(fd, self._sock_sendall, fut, sock, data) | ||
# use a trick with a list in closure to store a mutable state | ||
self.add_writer(fd, self._sock_sendall, fut, sock, data, [n]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why do we want to have a mutable state here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot pass just n
-- need either a mutable object or re-add a writer after every sock.send()
call until all data is sent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theorically speaking, memoryview should be closed after using.
But it is ignored often. Unlike file.close(), not closing memoryview is not a real problem on PyPy.
I want portable version of os.pwrite(fd, buf, start)
, instead of abusing memoryview though...
Sorry, forgot to merge it 3 months ago |
No NEWs is needed since the problem was introduced on master only and never released.
https://bugs.python.org/issue35589