| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -219,7 +219,10 @@ function bindServerHandle(self, options, errCb) { | |||
| 219 | 219 | const state = self[kStateSymbol]; | |
| 220 | 220 | cluster._getServer(self, options, (err, handle) => { | |
| 221 | 221 | if (err) { | |
| 222 | - errCb(err); | ||
| 222 | + // Do not call callback if socket is closed | ||
| 223 | + if (state.handle) { | ||
| 224 | + errCb(err); | ||
| 225 | + } | ||
| 223 | 226 | return; | |
| 224 | 227 | } | |
| 225 | 228 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,18 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const dgram = require('dgram'); | ||
| 4 | + const cluster = require('cluster'); | ||
| 5 | + | ||
| 6 | + if (cluster.isPrimary) { | ||
| 7 | + cluster.fork(); | ||
| 8 | + } else { | ||
| 9 | + // When the socket attempts to bind, it requests a handle from the cluster. | ||
| 10 | + // Force the cluster to send back an error code. | ||
| 11 | + const socket = dgram.createSocket('udp4'); | ||
| 12 | + cluster._getServer = function(self, options, callback) { | ||
| 13 | + socket.close(() => { cluster.worker.disconnect(); }); | ||
| 14 | + callback(-1); | ||
| 15 | + }; | ||
| 16 | + socket.on('error', common.mustNotCall()); | ||
| 17 | + socket.bind(); | ||
| 18 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments