Permalink
Browse files

[api] Dont emit the `carapace::port` event if the port that was bound…

… is in `carapace.reserved`
  • Loading branch information...
1 parent bd7bd24 commit bbf60d707fa1a4772764baaf3f83a87c93b630bb @indexzero indexzero committed Aug 8, 2011
Showing with 16 additions and 6 deletions.
  1. +16 −6 lib/net.js
View
@@ -104,14 +104,24 @@ net.Server.prototype._doListen = function () {
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?
//
- carapace.servers[desired] = self;
- carapace.emit('carapace::port', {
- id: carapace.id,
- desired: desired,
- port: actual
- });
+ if (carapace.reserved.indexOf(actual) === -1) {
+ carapace.emit('carapace::port', {
+ id: carapace.id,
+ desired: desired,
+ port: actual
+ });
+ }
}
catch (err) {
self.close();

0 comments on commit bbf60d7

Please sign in to comment.