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

net: deprecate _setSimultaneousAccepts() undocumented function #23760

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();