Skip to content
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

Avoid leak when stopping server #334

Merged
merged 1 commit into from
Mar 4, 2014
Merged

Avoid leak when stopping server #334

merged 1 commit into from
Mar 4, 2014

Conversation

aydany
Copy link

@aydany aydany commented Mar 4, 2014

If accept fails, e.g., because the server is no longer listening the
connection object is not terminated and it results in a memory leak:
connection -> handler -> connection.

Note: terminating connections that are not "accepted" results in asio error 10009 (invalid socket), since the OS socket is not created until accept succeeds. While this error appears to be harmless con->terminate() probably needs to be reworked to avoid generating a spurious log warning.

In addition, during stop, the endpoint goes through the accept loop one time too many: stop_listening() results in the current accept to fail with operation_cancelled, but then handle_accept calls accept_async unconditionally. In this case the call to accept_async is not necessary.

Thanks,
--aydan

If accept fails, e.g., because the server is no longer listening the
connection object is not terminated and it results in a memory leak:
connection -> handler -> connection.
zaphoyd added a commit that referenced this pull request Mar 4, 2014
Avoid leak when stopping server
@zaphoyd zaphoyd merged commit 7eedf25 into zaphoyd:master Mar 4, 2014
zaphoyd added a commit that referenced this pull request Mar 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants