mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
net_uv: throw if Server.prototype.close() is called twice
Follows net_legacy behaviour.
This commit is contained in:
@@ -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');
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user