Poco::Net::HTTPServer::stopAll() not working as expected #436

kblaschke opened this Issue May 2, 2014 · 0 comments


None yet
2 participants

kblaschke commented May 2, 2014

When stopping a Poco::Net::HTTPServer using the stopAll() method, the server won't stop properly if under heavy load. All open connections will be closed, but the server is still accepting new connections during the notification period, before actually closing down the server listening socket. These connections will not be closed, and continue to serve requests if they're using Keep-Alive.

How to reproduce:

  • Implement a simple HTTP server which uses unlimited Keep-Alive connections
  • Use stopAll() to end the server, and use joinAll() on the server's thread pool to wait until all connection threads are finished
  • Run the service, and hammer it with jMeter etc. with enabled Keep-Alive to simulate load
  • Stop the service e.g. by using Ctrl+c
  • The service will close the socket, but continue to serve a number of connections

A simple fix is swapping the two lines in HTTPServer::stopAll(), so the server socket will be closed before ending already-open connections. See the pull request below.
Currently, a workaround has to be used - first call stop(), then stopAll().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment