node-modules / agentkeepalive

Support keepalive http agent.
MIT License
579 stars 57 forks source link

auto detect dead lock sockets #6

Closed fengmk2 closed 10 years ago

fengmk2 commented 10 years ago

https://github.com/node-modules/urllib/issues/37

If socket close event not emit, need a way to detect those dead sockets. And close them.

fengmk2 commented 10 years ago

agentRemove a free socket... then it wont remove from free sockets queue, then it was reuse, close event was remove, so it will leak on working sockets queue...

fengmk2 commented 10 years ago

Bug is a socket can emit 'agentRemove' event, it should be on working sockets queue.

fengmk2 commented 10 years ago

Another dead lock flow:

  1. httpclient.responseOnEnd(): response Connection: close => socket.destroySoon() https://github.com/joyent/node/blob/master/lib/_http_client.js#L435
  2. socket.destroySoon(): socket waiting finish event https://github.com/joyent/node/blob/master/lib/net.js#L416
  3. socket.end() maybe lost the FIN packet and the socket finish event never fire. https://github.com/joyent/node/blob/master/lib/_stream_writable.js#L441
fengmk2 commented 10 years ago

The only solution is set a timer on working sockets list.

fengmk2 commented 10 years ago

https://github.com/joyent/node/pull/8135