| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent abf86ad commit f574bd4
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,31 +127,29 @@ function RoundRobinHandle(key, address, port, addressType, backlog, fd) { | |||
| 127 | 127 | else | |
| 128 | 128 | this.server.listen(address); // UNIX socket path. | |
| 129 | 129 | ||
| 130 | - var self = this; | ||
| 131 | - this.server.once('listening', function() { | ||
| 132 | - self.handle = self.server._handle; | ||
| 133 | - self.handle.onconnection = self.distribute.bind(self); | ||
| 134 | - self.server._handle = null; | ||
| 135 | - self.server = null; | ||
| 130 | + this.server.once('listening', () => { | ||
| 131 | + this.handle = this.server._handle; | ||
| 132 | + this.handle.onconnection = (err, handle) => this.distribute(err, handle); | ||
| 133 | + this.server._handle = null; | ||
| 134 | + this.server = null; | ||
| 136 | 135 | }); | |
| 137 | 136 | } | |
| 138 | 137 | ||
| 139 | 138 | RoundRobinHandle.prototype.add = function(worker, send) { | |
| 140 | 139 | assert(worker.id in this.all === false); | |
| 141 | 140 | this.all[worker.id] = worker; | |
| 142 | 141 | ||
| 143 | - var self = this; | ||
| 144 | - function done() { | ||
| 145 | - if (self.handle.getsockname) { | ||
| 142 | + const done = () => { | ||
| 143 | + if (this.handle.getsockname) { | ||
| 146 | 144 | var out = {}; | |
| 147 | - self.handle.getsockname(out); | ||
| 145 | + this.handle.getsockname(out); | ||
| 148 | 146 | // TODO(bnoordhuis) Check err. | |
| 149 | 147 | send(null, { sockname: out }, null); | |
| 150 | 148 | } else { | |
| 151 | 149 | send(null, null, null); // UNIX socket. | |
| 152 | 150 | } | |
| 153 | - self.handoff(worker); // In case there are connections pending. | ||
| 154 | - } | ||
| 151 | + this.handoff(worker); // In case there are connections pending. | ||
| 152 | + }; | ||
| 155 | 153 | ||
| 156 | 154 | if (this.server === null) return done(); | |
| 157 | 155 | // Still busy binding. | |
@@ -193,13 +191,13 @@ RoundRobinHandle.prototype.handoff = function(worker) { | |||
| 193 | 191 | return; | |
| 194 | 192 | } | |
| 195 | 193 | var message = { act: 'newconn', key: this.key }; | |
| 196 | - var self = this; | ||
| 197 | - sendHelper(worker.process, message, handle, function(reply) { | ||
| 194 | + | ||
| 195 | + sendHelper(worker.process, message, handle, (reply) => { | ||
| 198 | 196 | if (reply.accepted) | |
| 199 | 197 | handle.close(); | |
| 200 | 198 | else | |
| 201 | - self.distribute(0, handle); // Worker is shutting down. Send to another. | ||
| 202 | - self.handoff(worker); | ||
| 199 | + this.distribute(0, handle); // Worker is shutting down. Send to another. | ||
| 200 | + this.handoff(worker); | ||
| 203 | 201 | }); | |
| 204 | 202 | }; | |
| 205 | 203 | ||
@@ -414,7 +412,7 @@ function masterInit() { | |||
| 414 | 412 | cluster.disconnect = function(cb) { | |
| 415 | 413 | var workers = Object.keys(cluster.workers); | |
| 416 | 414 | if (workers.length === 0) { | |
| 417 | - process.nextTick(intercom.emit.bind(intercom, 'disconnect')); | ||
| 415 | + process.nextTick(() => intercom.emit('disconnect')); | ||
| 418 | 416 | } else { | |
| 419 | 417 | for (var key in workers) { | |
| 420 | 418 | key = workers[key]; | |
@@ -436,7 +434,7 @@ function masterInit() { | |||
| 436 | 434 | signo = signo || 'SIGTERM'; | |
| 437 | 435 | var proc = this.process; | |
| 438 | 436 | if (this.isConnected()) { | |
| 439 | - this.once('disconnect', proc.kill.bind(proc, signo)); | ||
| 437 | + this.once('disconnect', () => proc.kill(signo)); | ||
| 440 | 438 | this.disconnect(); | |
| 441 | 439 | return; | |
| 442 | 440 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments