Skip to content

Commit 1523111

Browse files
committed
net: deprecate _setSimultaneousAccepts() undocumented function
This is an undocumented utility function that is of questionable utility. Fixes: #18391 PR-URL: #23760 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 24cb1f3 commit 1523111

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

‎doc/api/deprecations.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,20 @@ undocumented `COUNTER_NET_SERVER_CONNECTION()`,
22642264
`COUNTER_HTTP_SERVER_RESPONSE()`, `COUNTER_HTTP_CLIENT_REQUEST()`, and
22652265
`COUNTER_HTTP_CLIENT_RESPONSE()` functions have been deprecated.
22662266
2267+
<a id="DEP00XX"></a>
2268+
### DEP00XX: net._setSimultaneousAccepts()
2269+
<!-- YAML
2270+
changes:
2271+
- version: REPLACEME
2272+
pr-url: https://github.com/nodejs/node/pull/23760
2273+
description: Runtime deprecation.
2274+
-->
2275+
2276+
The undocumented `net._setSimultaneousAccepts()` function was originally
2277+
intended for debugging and performance tuning when using the `child_process`
2278+
and `cluster` modules on Windows. The function is not generally useful and
2279+
is being removed. See discussion here:
2280+
https://github.com/nodejs/node/issues/18391
22672281
22682282
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
22692283
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size

‎lib/internal/child_process.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,7 @@ function setupChannel(target, channel){
604604

605605
// Update simultaneous accepts on Windows
606606
if(process.platform==='win32'){
607-
handle._simultaneousAccepts=false;
608-
net._setSimultaneousAccepts(handle);
607+
handle.setSimultaneousAccepts(false);
609608
}
610609

611610
// Convert handle object
@@ -700,8 +699,8 @@ function setupChannel(target, channel){
700699
message=message.msg;
701700

702701
// Update simultaneous accepts on Windows
703-
if(obj.simultaneousAccepts){
704-
net._setSimultaneousAccepts(handle);
702+
if(obj.simultaneousAccepts&&process.platform==='win32'){
703+
handle.setSimultaneousAccepts(true);
705704
}
706705
}elseif(this._handleQueue&&
707706
!(message&&(message.cmd==='NODE_HANDLE_ACK'||

‎lib/net.js‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,11 +1668,18 @@ Server.prototype.unref = function(){
16681668
};
16691669

16701670
var_setSimultaneousAccepts;
1671+
varwarnSimultaneousAccepts=true;
16711672

16721673
if(process.platform==='win32'){
16731674
varsimultaneousAccepts;
16741675

16751676
_setSimultaneousAccepts=function(handle){
1677+
if(warnSimultaneousAccepts){
1678+
process.emitWarning(
1679+
'net._setSimultaneousAccepts() is deprecated and will be removed.',
1680+
'DeprecationWarning','DEP00XX');
1681+
warnSimultaneousAccepts=false;
1682+
}
16761683
if(handle===undefined){
16771684
return;
16781685
}
@@ -1688,7 +1695,14 @@ if (process.platform === 'win32'){
16881695
}
16891696
};
16901697
}else{
1691-
_setSimultaneousAccepts=function(){};
1698+
_setSimultaneousAccepts=function(){
1699+
if(warnSimultaneousAccepts){
1700+
process.emitWarning(
1701+
'net._setSimultaneousAccepts() is deprecated and will be removed.',
1702+
'DeprecationWarning','DEP00XX');
1703+
warnSimultaneousAccepts=false;
1704+
}
1705+
};
16921706
}
16931707

16941708
module.exports={
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Flags: --no-warnings
2+
'use strict';
3+
4+
const{
5+
expectWarning
6+
}=require('../common');
7+
const{
8+
_setSimultaneousAccepts
9+
}=require('net');
10+
11+
expectWarning(
12+
'DeprecationWarning',
13+
'net._setSimultaneousAccepts() is deprecated and will be removed.',
14+
'DEP00XX');
15+
16+
_setSimultaneousAccepts();

0 commit comments

Comments
(0)