-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: #7061 PR-URL: #7066 Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
Showing
2 changed files
with
57 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |