Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs clarification #1080

Closed
boneskull opened this issue Jan 26, 2018 · 4 comments
Closed

docs clarification #1080

boneskull opened this issue Jan 26, 2018 · 4 comments

Comments

@boneskull
Copy link

  • Node.js Version: 9.4.0
  • OS: macos
  • Scope (install, code, runtime, meta, other?): docs
  • Module (and version) (if relevant): net

I'm checking out the documentation on IPC connections, but the wording is unclear to me.

It says (basically) that a named pipe in UNIX "persist until unlinked". This seems to imply that one must manually unlink when finished using it. This is untrue, because calling close() on the Server object will apparently do so for you (?).

In Windows, it claims pipes will "not persist", and are removed "when the last reference to them is closed". How exactly does this differ from the UNIX behavior? Does it have something to do with garbage collection, or the socket object falling out of scope...?

Thanks!

@gireeshpunathil
Copy link
Member

persist until unlinked is true, and this unlinking is performed on server close. So you are right, there is an ambiguity in this section in terms of who unlinks the pipe. Would you be interested in improving it through a PR?

I am not sure how exactly the windows (external) behavior is different from UNIX,
/cc @nodejs/platform-windows

@gireeshpunathil
Copy link
Member

@boneskull - a PR in progress to address your concerns.

Does it have something to do with garbage collection, or the socket object falling out of scope...?

I did the below check and determined that the collection is done by the operating system, not Node.js . As you can see, the named pipe is removed when the program is abruptly terminated. This is different from UNIX where the DOMAIN socket persists on such abrupt termination. So the reference count is maintained by Windows.

var net = require('net')
const p= '\\\\.\\pipe\\test.sock'
  console.log(p)
var k = net.createServer((s) => {
  s.end('hello!')
}).listen(p, () => {
  var socket = net.connect(p)
  socket.on('data', (d) => {
    // k.close()
  })
})
$ node 1080.js
\\.\pipe\test.sock
^C  // kill abruptly
$

from the powershell:

PS> [System.IO.Directory]::GetFiles("\\.\\pipe\\") | grep test
\\.\\pipe\\test.sock
PS> [System.IO.Directory]::GetFiles("\\.\\pipe\\") | grep test
PS>

Hoep this helps!

gireeshpunathil added a commit to gireeshpunathil/node that referenced this issue Mar 21, 2018
In UNIX, the domain sockets once created persists until unlinked.
Clarify which ones are persisted and which ones are cleared manually.

In Windows, named pipes are cleared based on reference count,
implemented by the underlying system. Disambiguate this from
Garbage collection of the Node.js runtime.

Refs: nodejs/help#1080
@gireeshpunathil
Copy link
Member

@boneskull - have a look at the PR and see if you believe the changes meets your expected clarity and coverage.

gireeshpunathil added a commit to nodejs/node that referenced this issue Apr 6, 2018
In UNIX, the domain sockets once created persists until unlinked.
Clarify which ones are persisted and which ones are cleared manually.

In Windows, named pipes are cleared based on reference count,
implemented by the underlying system. Disambiguate this from
Garbage collection of the Node.js runtime.

Refs: nodejs/help#1080
PR-URL: #19471
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@gireeshpunathil
Copy link
Member

closing as addressed.

Trott pushed a commit to Trott/io.js that referenced this issue Apr 6, 2018
In UNIX, the domain sockets once created persists until unlinked.
Clarify which ones are persisted and which ones are cleared manually.

In Windows, named pipes are cleared based on reference count,
implemented by the underlying system. Disambiguate this from
Garbage collection of the Node.js runtime.

Refs: nodejs/help#1080

PR-URL: nodejs#19471
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
targos pushed a commit to nodejs/node that referenced this issue Apr 12, 2018
In UNIX, the domain sockets once created persists until unlinked.
Clarify which ones are persisted and which ones are cleared manually.

In Windows, named pipes are cleared based on reference count,
implemented by the underlying system. Disambiguate this from
Garbage collection of the Node.js runtime.

Refs: nodejs/help#1080

PR-URL: #19471
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants