-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
socketserver.BaseServer._handle_request_noblock() doesn't shutdown request if verify_request is False #70497
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
Comments
When socketserver.BaseServer.verify_request() return False then we do not call shutdown_request. If we will take the TCPServer as example we will call get_request thus calling socket.accept() and creating a new socket but we will not call shutdown_request to close the unused socket. |
Had a small mistake in the previous patch (did not notice process_request) call shutdown_request. fixed the patch |
The patch looks good to me. Are you interested in writing a unit test for it? Having said that, it might be a tricky test to write. |
I added a test to check the specific bug. There seems to be no testing at all on the verify_request feature so I will create some in different issue in the future. |
Thanks for the test, but it is a bit confusing to have the shutdown_request() method call finish_request() and actually do normal request handling. Maybe it would be better to not handle the request (and not test that a response is received), and just check that shutdown_request() is called or that the client socket is explicitly closed. |
I changed the test to just check that shutdown_request is called. Hope this is more clear then the previous test. |
Yes this patch looks pretty good, thanks |
New changeset 651a6d47bc78 by Martin Panter in branch '3.5': New changeset 0768edf5878d by Martin Panter in branch 'default': New changeset e0fbd25f0b36 by Martin Panter in branch '2.7': |
For the Python 2 version I had to make some small changes to the test. I used indirection instead of “nonlocal”, and replaced the super() call because the classes are apparently the wrong kind for super(). |
Some of the buildbots failed (e.g. <http://buildbot.python.org/all/builders/ARMv7%20Ubuntu%202.7/builds/1145/steps/test/logs/stdio\>). I think the server is run in a separate thread, and the problem is a race between shutdown_request() being called and run_server returning. |
New changeset cba717fa8e10 by Martin Panter in branch '2.7': New changeset 537608bafa5a by Martin Panter in branch '3.5': New changeset c791d57c8168 by Martin Panter in branch 'default': |
The race depended on how whether serve_forever had a chance to hande the first request before the main thread told it to stop. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: