Browse Source

net_uv: throw if Server.prototype.close() is called twice

Follows net_legacy behaviour.
v0.7.4-release
Ben Noordhuis 13 years ago
parent
commit
984dc057e3
  1. 9
      lib/net_uv.js
  2. 6
      test/simple/test-http-unix-socket.js

9
lib/net_uv.js

@ -631,10 +631,13 @@ function onconnection(clientHandle) {
Server.prototype.close = function() {
if (this._handle != null) {
this._handle.close();
this._handle = null;
if (!this._handle) {
// Throw error. Follows net_legacy behaviour.
throw new Error('Not running');
}
this._handle.close();
this._handle = null;
this.emit('close');
};

6
test/simple/test-http-unix-socket.js

@ -75,8 +75,12 @@ server.listen(common.PIPE, function() {
});
process.on('exit', function() {
server.close();
assert.ok(status_ok);
assert.ok(headers_ok);
assert.ok(body_ok);
// Double close should throw. Follows net_legacy behaviour.
assert.throws(function() {
server.close();
});
});

Loading…
Cancel
Save