Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

net: unref() is not persistent #7077

Closed
bnoordhuis opened this issue Feb 8, 2014 · 2 comments
Closed

net: unref() is not persistent #7077

bnoordhuis opened this issue Feb 8, 2014 · 2 comments

Comments

@bnoordhuis
Copy link
Member

var net = require('net');
var server = net.createServer();
server.unref();
server.listen();
net.connect(server.address().port).unref();

It hangs because of the unref() that comes before listen() and the one after connect(). In that vein:

require('net').connect(42).unref();

It fails with ECONNREFUSED because the unref() is a no-op. The expected behavior for both scripts is that they simply quit. Affects v0.10 and master.

The documentation doesn't mention when it's okay to call unref(). For the sake of user friendliness, net.Socket and net.Server should remember the ref state and retroactively apply it when the handle is created. Probably applies to other handle types as well.

@daviddias daviddias added the net label Feb 14, 2014
@tjfontaine tjfontaine self-assigned this Feb 19, 2014
@tjfontaine tjfontaine added this to the v0.10 milestone Feb 19, 2014
@tjfontaine
Copy link

Right this is definitely a bug that should be squashed. Assigned to me.

@orangemocha orangemocha assigned cjihrig and unassigned tjfontaine Jan 3, 2015
evanlucas added a commit to evanlucas/node that referenced this issue Feb 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue Feb 20, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue Feb 20, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue Feb 23, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue Mar 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue Mar 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue Apr 24, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue May 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue May 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue May 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue May 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to evanlucas/node that referenced this issue May 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572
evanlucas added a commit to nodejs/node that referenced this issue May 19, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572

Fixes: nodejs/node-v0.x-archive#7077
Fixes: nodejs/node-v0.x-archive#8572
PR-URL: #1518
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
@cjihrig
Copy link

cjihrig commented May 19, 2015

nodejs/node@85d9983 just landed. It can either be ported, or we can close this and pick up the changes in the converged branch.

@cjihrig cjihrig closed this as completed May 19, 2015
@cjihrig cjihrig reopened this May 19, 2015
andrewdeandrade pushed a commit to andrewdeandrade/node that referenced this issue Jun 3, 2015
Remembers net.Socket options called before connect and retroactively
applies them after the handle has been created.

This change makes the following function calls more user-friendly:

- setKeepAlive()
- setNoDelay()
- ref()
- unref()

Related: nodejs/node-v0.x-archive#7077 and
nodejs/node-v0.x-archive#8572

Fixes: nodejs/node-v0.x-archive#7077
Fixes: nodejs/node-v0.x-archive#8572
PR-URL: nodejs/node#1518
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
@cjihrig cjihrig closed this as completed Dec 3, 2015
@cjihrig cjihrig removed their assignment Dec 3, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants