Skip to content

http: fixed socket destruction, timeout and leaking

Rodrigo Muino Tomonari requested to merge github/fork/tshemsedinov/master into master
  • Prevent 2 minutes sockets and memory hanging/leaking after server finished writing last response and connection hang inactive waiting for nothing (it is actual only in keep-alive mode, single HTTP requests does not hanging for 2 minutes, browsers do not reuse them and somehow do not close them too)
  • Fixed res._last, because it was not calculated correctly in this place before this PR and as a result socket.destroySoon() was never executed
  • Implemented server.keepAliveTimeout (default to 5 seconds) in addition to server.timeout
  • Prevent firing timeout event on server for finished and closed sockets
  • Removed socket.destroySoon() because it worked well on prefinish and have no sense on finish

Memory usage comparison before and after: memory

Socket handlers usage comparison before and after: sockets

Tests changed and provided new. Related PR: https://github.com/nodejs/node/pull/1411 by @indutny Related Issue: https://github.com/joyent/node/issues/3460 Article about this problem (RU): http://habrahabr.ru/post/264851/

Merge request reports

Loading