2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2012-02-14 04:30:09 +01:00
|
|
|
// Ensure that if a dgram socket is closed before the DNS lookup completes, it
|
|
|
|
// won't crash.
|
|
|
|
|
2016-01-13 21:42:45 +01:00
|
|
|
const common = require('../common');
|
2016-07-15 21:43:24 +02:00
|
|
|
const assert = require('assert');
|
2016-01-13 21:42:45 +01:00
|
|
|
const dgram = require('dgram');
|
2012-02-14 04:30:09 +01:00
|
|
|
|
2016-01-26 00:00:06 +01:00
|
|
|
var buf = Buffer.alloc(1024, 42);
|
2012-02-14 04:30:09 +01:00
|
|
|
|
|
|
|
var socket = dgram.createSocket('udp4');
|
2013-11-19 08:38:48 +01:00
|
|
|
var handle = socket._handle;
|
2016-07-15 21:43:24 +02:00
|
|
|
|
2013-08-09 02:33:40 +02:00
|
|
|
socket.send(buf, 0, buf.length, common.PORT, 'localhost');
|
2016-07-15 21:43:24 +02:00
|
|
|
assert.strictEqual(socket.close(common.mustCall(function() {})), socket);
|
|
|
|
socket.on('close', common.mustCall(function() {}));
|
2013-11-19 08:38:48 +01:00
|
|
|
socket = null;
|
|
|
|
|
|
|
|
// Verify that accessing handle after closure doesn't throw
|
|
|
|
setImmediate(function() {
|
|
|
|
setImmediate(function() {
|
|
|
|
console.log('Handle fd is: ', handle.fd);
|
|
|
|
});
|
|
|
|
});
|