mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
138eb32be1
When not allowing half open, handle.close would be invoked before shutdown has been called and completed causing a potential data race. Fixes: https://github.com/nodejs/node/issues/32486#issuecomment-604072559 PR-URL: https://github.com/nodejs/node/pull/32491 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
26 lines
732 B
JavaScript
26 lines
732 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const server = net.createServer(common.mustCall((socket) => {
|
|
socket.end(Buffer.alloc(1024));
|
|
})).listen(0, common.mustCall(() => {
|
|
const socket = net.connect(server.address().port);
|
|
assert.strictEqual(socket.allowHalfOpen, false);
|
|
socket.resume();
|
|
socket.on('end', common.mustCall(() => {
|
|
process.nextTick(() => {
|
|
// Ensure socket is not destroyed straight away
|
|
// without proper shutdown.
|
|
assert(!socket.destroyed);
|
|
server.close();
|
|
});
|
|
}));
|
|
socket.on('finish', common.mustCall(() => {
|
|
assert(!socket.destroyed);
|
|
}));
|
|
socket.on('close', common.mustCall());
|
|
}));
|