Skip to content

Commit

Permalink
[api] Dont emit the carapace::port event if the port that was bound…
Browse files Browse the repository at this point in the history
… is in `carapace.reserved`
  • Loading branch information
indexzero committed Aug 8, 2011
1 parent bd7bd24 commit bbf60d7
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/net.js
Expand Up @@ -103,15 +103,25 @@ net.Server.prototype._doListen = function () {
try { try {
listen(self.fd, self._backlog || 128); listen(self.fd, self._backlog || 128);


//
// Store the server that has listened on the `desired` port
// on the carapace itself, indexed by port.
//
carapace.servers[desired] = self;

//
// If the desired port is not in the list of `carapace.reserved`
// ports then emit the `carapace::port` event.
// //
// Remark: How does this work with multi-server programs? // Remark: How does this work with multi-server programs?
// //
carapace.servers[desired] = self; if (carapace.reserved.indexOf(actual) === -1) {
carapace.emit('carapace::port', { carapace.emit('carapace::port', {
id: carapace.id, id: carapace.id,
desired: desired, desired: desired,
port: actual port: actual
}); });
}
} }
catch (err) { catch (err) {
self.close(); self.close();
Expand Down

0 comments on commit bbf60d7

Please sign in to comment.