| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,6 +98,10 @@ RoundRobinHandle.prototype.remove = function(worker) { | |||
| 98 | 98 | }; | |
| 99 | 99 | ||
| 100 | 100 | RoundRobinHandle.prototype.distribute = function(err, handle) { | |
| 101 | + // If `accept` fails just skip it (handle is undefined) | ||
| 102 | + if (err) { | ||
| 103 | + return; | ||
| 104 | + } | ||
| 101 | 105 | append(this.handles, handle); | |
| 102 | 106 | // eslint-disable-next-line node-core/no-array-destructuring | |
| 103 | 107 | const [ workerEntry ] = this.free; // this.free is a SafeMap | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + // Flags: --expose-internals | ||
| 2 | + 'use strict'; | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const net = require('net'); | ||
| 6 | + const cluster = require('cluster'); | ||
| 7 | + const rr = require('internal/cluster/round_robin_handle'); | ||
| 8 | + | ||
| 9 | + if (cluster.isPrimary) { | ||
| 10 | + const distribute = rr.prototype.distribute; | ||
| 11 | + rr.prototype.distribute = function(err, handle) { | ||
| 12 | + assert.strictEqual(err, 0); | ||
| 13 | + handle.close(); | ||
| 14 | + distribute.call(this, -1, undefined); | ||
| 15 | + }; | ||
| 16 | + cluster.schedulingPolicy = cluster.SCHED_RR; | ||
| 17 | + cluster.fork(); | ||
| 18 | + } else { | ||
| 19 | + const server = net.createServer(common.mustNotCall()); | ||
| 20 | + server.listen(0, common.mustCall(() => { | ||
| 21 | + | ||
| 22 | + const socket = net.connect(server.address().port); | ||
| 23 | + | ||
| 24 | + socket.on('close', common.mustCall(() => { | ||
| 25 | + server.close(common.mustCall(() => { | ||
| 26 | + process.disconnect(); | ||
| 27 | + })); | ||
| 28 | + })); | ||
| 29 | + })); | ||
| 30 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments