diff options
author | Matteo Collina <hello@matteocollina.com> | 2016-05-30 18:29:27 +0200 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2016-07-13 17:49:04 +0200 |
commit | a2a711a37377cc0d732981832f01b24c55b24c19 (patch) | |
tree | f808dde6a6af0d20e551d53b2e9a8673cc97d026 /test/parallel/test-dgram-close-in-listening.js | |
parent | c01d61af59dbcf528d7227badd2f3757fa596ec2 (diff) | |
download | android-node-v8-a2a711a37377cc0d732981832f01b24c55b24c19.tar.gz android-node-v8-a2a711a37377cc0d732981832f01b24c55b24c19.tar.bz2 android-node-v8-a2a711a37377cc0d732981832f01b24c55b24c19.zip |
dgram: generalized send queue to handle close
If the udp socket is not ready and we are accumulating
messages to send, it needs to delay closing the socket when
all messages are flushed.
Fixes: https://github.com/nodejs/node/issues/7061
PR-URL: https://github.com/nodejs/node/pull/7066
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/parallel/test-dgram-close-in-listening.js')
-rw-r--r-- | test/parallel/test-dgram-close-in-listening.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/parallel/test-dgram-close-in-listening.js b/test/parallel/test-dgram-close-in-listening.js new file mode 100644 index 0000000000..e181f40de6 --- /dev/null +++ b/test/parallel/test-dgram-close-in-listening.js @@ -0,0 +1,18 @@ +'use strict'; +// Ensure that if a dgram socket is closed before the sendQueue is drained +// will not crash + +const common = require('../common'); +const dgram = require('dgram'); + +const buf = Buffer.alloc(1024, 42); + +const socket = dgram.createSocket('udp4'); + +socket.on('listening', function() { + socket.close(); +}); + +// adds a listener to 'listening' to send the data when +// the socket is available +socket.send(buf, 0, buf.length, common.PORT, 'localhost'); |