| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ad2b272 commit 7c35fbc
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,9 @@ const cluster = require('cluster'); | |||
| 7 | 7 | const net = require('net'); | |
| 8 | 8 | const util = require('util'); | |
| 9 | 9 | ||
| 10 | + var connectcount = 0; | ||
| 11 | + var sendcount = 0; | ||
| 12 | + | ||
| 10 | 13 | if (!cluster.isMaster) { | |
| 11 | 14 | // Exit on first received handle to leave the queue non-empty in master | |
| 12 | 15 | process.on('message', function() { | |
@@ -25,6 +28,21 @@ var server = net.createServer(function(s) { | |||
| 25 | 28 | function send(callback) { | |
| 26 | 29 | var s = net.connect(common.PORT, function() { | |
| 27 | 30 | worker.send({}, s, callback); | |
| 31 | + connectcount++; | ||
| 32 | + }); | ||
| 33 | + | ||
| 34 | + // Errors can happen if the connections | ||
| 35 | + // are still happening while the server has been closed. | ||
| 36 | + // This can happen depending on how the messages are | ||
| 37 | + // bundled into packets. If they all make it into the first | ||
| 38 | + // one then no errors will occur, otherwise the server | ||
| 39 | + // may have been closed by the time the later ones make | ||
| 40 | + // it to the server side. | ||
| 41 | + // We ignore any errors that occur after some connections | ||
| 42 | + // get through | ||
| 43 | + s.on('error', function(err) { | ||
| 44 | + if (connectcount < 3) | ||
| 45 | + console.log(err); | ||
| 28 | 46 | }); | |
| 29 | 47 | } | |
| 30 | 48 | ||
@@ -36,5 +54,9 @@ var server = net.createServer(function(s) { | |||
| 36 | 54 | ||
| 37 | 55 | // Queue up several handles, to make `process.disconnect()` wait | |
| 38 | 56 | for (var i = 0; i < 100; i++) | |
| 39 | - send(); | ||
| 57 | + send(function(err) { | ||
| 58 | + if (err && sendcount < 3) | ||
| 59 | + console.log(err); | ||
| 60 | + sendcount++; | ||
| 61 | + }); | ||
| 40 | 62 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments