Skip to content

Commit

Permalink
net: refactor check for Windows
Browse files Browse the repository at this point in the history
PR-URL: nodejs#33497
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
rickyes authored and codebytere committed Jun 30, 2020
1 parent 8fc790b commit b23e4b2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/net.js
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 @@ -335,8 +337,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 @@ -1024,7 +1025,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 @@ -1227,7 +1228,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 @@ -1710,7 +1711,7 @@ Server.prototype.unref = function() {
let _setSimultaneousAccepts;
let warnSimultaneousAccepts = true;

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

_setSimultaneousAccepts = function(handle) {
Expand Down

0 comments on commit b23e4b2

Please sign in to comment.