forked from nodejs/node
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: add support for finished after .destroy()
Calling `finished(socket, cb)` would previously not invoked the callback if the socket was already detroyed. PR-URL: nodejs#36635 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
4 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const net = require('net'); | ||
const { finished } = require('stream'); | ||
|
||
const server = net.createServer(function(con) { | ||
con.on('close', common.mustCall()); | ||
}); | ||
|
||
server.listen(0, common.mustCall(function() { | ||
const con = net.connect({ | ||
port: this.address().port | ||
}) | ||
.on('connect', () => { | ||
finished(con, common.mustCall()); | ||
con.destroy(); | ||
finished(con, common.mustCall()); | ||
con.on('close', common.mustCall(() => { | ||
finished(con, common.mustCall(() => { | ||
server.close(); | ||
})); | ||
})); | ||
}) | ||
.end(); | ||
})); |