Skip to content

Commit

Permalink
net: deprecate _setSimultaneousAccepts() undocumented function
Browse files Browse the repository at this point in the history
This is an undocumented utility function that is of questionable
utility.

Fixes: nodejs#18391
  • Loading branch information
jasnell committed Oct 25, 2018
1 parent 24cb1f3 commit 714c1aa
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
14 changes: 14 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,20 @@ undocumented `COUNTER_NET_SERVER_CONNECTION()`,
`COUNTER_HTTP_SERVER_RESPONSE()`, `COUNTER_HTTP_CLIENT_REQUEST()`, and
`COUNTER_HTTP_CLIENT_RESPONSE()` functions have been deprecated.
<a id="DEP00XX"></a>
### DEP00XX: net._setSimultaneousAccepts()
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/23760
description: Runtime deprecation.
-->
The undocumented `net._setSimultaneousAccepts()` function was originally
intended for debugging and performance tuning when using the `child_process`
and `cluster` modules on Windows. The function is not generally useful and
is being removed. See discussion here:
https://github.com/nodejs/node/issues/18391
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
Expand Down
7 changes: 3 additions & 4 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,7 @@ function setupChannel(target, channel) {

// Update simultaneous accepts on Windows
if (process.platform === 'win32') {
handle._simultaneousAccepts = false;
net._setSimultaneousAccepts(handle);
handle.setSimultaneousAccepts(false);
}

// Convert handle object
Expand Down Expand Up @@ -700,8 +699,8 @@ function setupChannel(target, channel) {
message = message.msg;

// Update simultaneous accepts on Windows
if (obj.simultaneousAccepts) {
net._setSimultaneousAccepts(handle);
if (obj.simultaneousAccepts && process.platform === 'win32') {
handle.setSimultaneousAccepts(true);
}
} else if (this._handleQueue &&
!(message && (message.cmd === 'NODE_HANDLE_ACK' ||
Expand Down
16 changes: 15 additions & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -1668,11 +1668,18 @@ Server.prototype.unref = function() {
};

var _setSimultaneousAccepts;
var warnSimultaneousAccepts = true;

if (process.platform === 'win32') {
var simultaneousAccepts;

_setSimultaneousAccepts = function(handle) {
if (warnSimultaneousAccepts) {
process.emitWarning(
'net._setSimultaneousAccepts() is deprecated and will be removed.',
'DeprecationWarning', 'DEP00XX');
warnSimultaneousAccepts = false;
}
if (handle === undefined) {
return;
}
Expand All @@ -1688,7 +1695,14 @@ if (process.platform === 'win32') {
}
};
} else {
_setSimultaneousAccepts = function() {};
_setSimultaneousAccepts = function() {
if (warnSimultaneousAccepts) {
process.emitWarning(
'net._setSimultaneousAccepts() is deprecated and will be removed.',
'DeprecationWarning', 'DEP00XX');
warnSimultaneousAccepts = false;
}
};
}

module.exports = {
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-net-deprecated-setsimultaneousaccepts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Flags: --no-warnings
'use strict';

const {
expectWarning
} = require('../common');
const {
_setSimultaneousAccepts
} = require('net');

expectWarning(
'DeprecationWarning',
'net._setSimultaneousAccepts() is deprecated and will be removed.',
'DEP00XX');

_setSimultaneousAccepts();

0 comments on commit 714c1aa

Please sign in to comment.