net: deprecate _setSimultaneousAccepts() undocumented function · nodejs/node@1523111 (original) (raw)
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2264,6 +2264,20 @@ undocumented `COUNTER_NET_SERVER_CONNECTION()`, | ||
2264 | 2264 | `COUNTER_HTTP_SERVER_RESPONSE()`, `COUNTER_HTTP_CLIENT_REQUEST()`, and |
2265 | 2265 | `COUNTER_HTTP_CLIENT_RESPONSE()` functions have been deprecated. |
2266 | 2266 | |
2267 | + | |
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 | |
2267 | 2281 | |
2268 | 2282 | [`--pending-deprecation`]: cli.html#cli_pending_deprecation |
2269 | 2283 | [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -604,8 +604,7 @@ function setupChannel(target, channel) { | ||
604 | 604 | |
605 | 605 | // Update simultaneous accepts on Windows |
606 | 606 | if (process.platform === 'win32') { |
607 | -handle._simultaneousAccepts = false; | |
608 | -net._setSimultaneousAccepts(handle); | |
607 | +handle.setSimultaneousAccepts(false); | |
609 | 608 | } |
610 | 609 | |
611 | 610 | // Convert handle object |
@@ -700,8 +699,8 @@ function setupChannel(target, channel) { | ||
700 | 699 | message = message.msg; |
701 | 700 | |
702 | 701 | // Update simultaneous accepts on Windows |
703 | -if (obj.simultaneousAccepts) { | |
704 | -net._setSimultaneousAccepts(handle); | |
702 | +if (obj.simultaneousAccepts && process.platform === 'win32') { | |
703 | +handle.setSimultaneousAccepts(true); | |
705 | 704 | } |
706 | 705 | } else if (this._handleQueue && |
707 | 706 | !(message && (message.cmd === 'NODE_HANDLE_ACK' | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1668,11 +1668,18 @@ Server.prototype.unref = function() { | ||
1668 | 1668 | }; |
1669 | 1669 | |
1670 | 1670 | var _setSimultaneousAccepts; |
1671 | +var warnSimultaneousAccepts = true; | |
1671 | 1672 | |
1672 | 1673 | if (process.platform === 'win32') { |
1673 | 1674 | var simultaneousAccepts; |
1674 | 1675 | |
1675 | 1676 | _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 | +} | |
1676 | 1683 | if (handle === undefined) { |
1677 | 1684 | return; |
1678 | 1685 | } |
@@ -1688,7 +1695,14 @@ if (process.platform === 'win32') { | ||
1688 | 1695 | } |
1689 | 1696 | }; |
1690 | 1697 | } 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 | +}; | |
1692 | 1706 | } |
1693 | 1707 | |
1694 | 1708 | module.exports = { |
Original file line number | Diff line number | Diff 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(); |