mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
net_uv: throw if Server.prototype.close() is called twice
Follows net_legacy behaviour.
This commit is contained in:
1 parent
345df289eb
commit
984dc057e3
2 files changed
+11
-4
No files matched your search
+6
-3
@@ -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