http: fixed socket destruction, timeout and leaking
- 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 resultsocket.destroySoon()
was never executed - Implemented
server.keepAliveTimeout
(default to 5 seconds) in addition toserver.timeout
- Prevent firing
timeout
event on server for finished and closed sockets - Removed
socket.destroySoon()
because it worked well onprefinish
and have no sense onfinish
Memory usage comparison before and after:
Socket handlers usage comparison before and after:
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/