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: refactor check for Windows #33497

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 6 additions & 5 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ const { kTimeout } = require('internal/timers');
const DEFAULT_IPV4_ADDR = '0.0.0.0';
const DEFAULT_IPV6_ADDR = '::';

const isWindows = process.platform === 'win32';

function noop() {}

function getFlags(ipv6Only) {
Expand Down Expand Up @@ -330,8 +332,7 @@ function Socket(options) {
this[async_id_symbol] = this._handle.getAsyncId();

if ((fd === 1 || fd === 2) &&
(this._handle instanceof Pipe) &&
process.platform === 'win32') {
(this._handle instanceof Pipe) && isWindows) {
// Make stdout and stderr blocking on Windows
err = this._handle.setBlocking(true);
if (err)
Expand Down Expand Up @@ -1004,7 +1005,7 @@ function lookupAndConnect(self, options) {
hints: options.hints || 0
};

if (process.platform !== 'win32' &&
if (!isWindows &&
dnsopts.family !== 4 &&
dnsopts.family !== 6 &&
dnsopts.hints === 0) {
Expand Down Expand Up @@ -1207,7 +1208,7 @@ function createServerHandle(address, port, addressType, fd, flags) {
assert(!address && !port);
} else if (port === -1 && addressType === -1) {
handle = new Pipe(PipeConstants.SERVER);
if (process.platform === 'win32') {
if (isWindows) {
const instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES);
if (!NumberIsNaN(instances)) {
handle.setPendingInstances(instances);
Expand Down Expand Up @@ -1690,7 +1691,7 @@ Server.prototype.unref = function() {
let _setSimultaneousAccepts;
let warnSimultaneousAccepts = true;

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

_setSimultaneousAccepts = function(handle) {
Expand Down