child_process: do not keep list of sent sockets
authorFedor Indutny <fedor.indutny@gmail.com>
Mon, 14 Jan 2013 17:08:20 +0000 (21:08 +0400)
committerisaacs <i@izs.me>
Thu, 17 Jan 2013 21:46:31 +0000 (13:46 -0800)
commitdb5ee0b3decace9b5d80ee535ce53183aff02909
treeb83b0a8546b1c898f9454f3cfc8eca72960ca33f
parentb7d76a1a7ba441ffb5dd0da05a226295f7a3a17c
child_process: do not keep list of sent sockets

Keeping list of all sockets that were sent to child process causes memory
leak and thus unacceptable (see #4587). However `server.close()` should
still work properly.

This commit introduces two options:

* child.send(socket, { track: true }) - will send socket and track its status.
  You should use it when you want `server.connections` to be a reliable
  number, and receive `close` event on sent sockets.
* child.send(socket) - will send socket without tracking it status. This
  performs much better, because of smaller number of RTT between master and
  child.

With both of these options `server.close()` will wait for all sent
sockets to get closed.
doc/api/child_process.markdown
doc/api/net.markdown
lib/child_process.js
lib/net.js
test/simple/test-child-process-fork-getconnections.js [new file with mode: 0644]
test/simple/test-child-process-fork-net2.js
test/simple/test-child-process-fork-track.js [new file with mode: 0644]