mirror of https://github.com/lukechilds/node.git
Browse Source
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>v7.x
2 changed files with 39 additions and 11 deletions
@ -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'); |
Loading…
Reference in new issue