| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6971630 commit b8d46f4
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,25 +1,26 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - var common = require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 4 | - var cluster = require('cluster'); | ||
| 5 | - var net = require('net'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const cluster = require('cluster'); | ||
| 5 | + const net = require('net'); | ||
| 6 | 6 | ||
| 7 | 7 | if (cluster.isMaster) { | |
| 8 | 8 | // Master opens and binds the socket and shares it with the worker. | |
| 9 | 9 | cluster.schedulingPolicy = cluster.SCHED_NONE; | |
| 10 | 10 | // Hog the TCP port so that when the worker tries to bind, it'll fail. | |
| 11 | - net.createServer(common.fail).listen(common.PORT, function() { | ||
| 12 | - var server = this; | ||
| 13 | - var worker = cluster.fork(); | ||
| 14 | - worker.on('exit', common.mustCall(function(exitCode) { | ||
| 11 | + const server = net.createServer(common.fail); | ||
| 12 | + | ||
| 13 | + server.listen(common.PORT, common.mustCall(() => { | ||
| 14 | + const worker = cluster.fork(); | ||
| 15 | + worker.on('exit', common.mustCall((exitCode) => { | ||
| 15 | 16 | assert.strictEqual(exitCode, 0); | |
| 16 | 17 | server.close(); | |
| 17 | 18 | })); | |
| 18 | - }); | ||
| 19 | + })); | ||
| 19 | 20 | } else { | |
| 20 | - var s = net.createServer(common.fail); | ||
| 21 | + const s = net.createServer(common.fail); | ||
| 21 | 22 | s.listen(common.PORT, common.fail.bind(null, 'listen should have failed')); | |
| 22 | - s.on('error', common.mustCall(function(err) { | ||
| 23 | + s.on('error', common.mustCall((err) => { | ||
| 23 | 24 | assert.strictEqual(err.code, 'EADDRINUSE'); | |
| 24 | 25 | process.disconnect(); | |
| 25 | 26 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments