|
@ -12,102 +12,90 @@ function makeAssert(message) { |
|
|
|
|
|
|
|
|
// child_process
|
|
|
// child_process
|
|
|
{ |
|
|
{ |
|
|
const assert = makeAssert('unrefed() not working on process_wrap'); |
|
|
const assert = makeAssert('isRefed() not working on process_wrap'); |
|
|
const spawn = require('child_process').spawn; |
|
|
const spawn = require('child_process').spawn; |
|
|
const cmd = common.isWindows ? 'rundll32' : 'ls'; |
|
|
const cmd = common.isWindows ? 'rundll32' : 'ls'; |
|
|
const cp = spawn(cmd); |
|
|
const cp = spawn(cmd); |
|
|
assert(Object.getPrototypeOf(cp._handle).hasOwnProperty('unrefed'), true); |
|
|
assert(Object.getPrototypeOf(cp._handle).hasOwnProperty('isRefed'), true); |
|
|
assert(cp._handle.unrefed(), false); |
|
|
assert(cp._handle.isRefed(), true); |
|
|
cp.unref(); |
|
|
cp.unref(); |
|
|
assert(cp._handle.unrefed(), true); |
|
|
assert(cp._handle.isRefed(), false); |
|
|
cp.ref(); |
|
|
cp.ref(); |
|
|
assert(cp._handle.unrefed(), false); |
|
|
assert(cp._handle.isRefed(), true); |
|
|
cp._handle.close(common.mustCall(() => assert(cp._handle.unrefed(), true))); |
|
|
cp._handle.close(common.mustCall(() => assert(cp._handle.isRefed(), false))); |
|
|
cp._handle.close(common.fail); |
|
|
|
|
|
assert(cp._handle.unrefed(), false); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// dgram
|
|
|
// dgram
|
|
|
{ |
|
|
{ |
|
|
const assert = makeAssert('unrefed() not working on udp_wrap'); |
|
|
const assert = makeAssert('isRefed() not working on udp_wrap'); |
|
|
const dgram = require('dgram'); |
|
|
const dgram = require('dgram'); |
|
|
|
|
|
|
|
|
const sock4 = dgram.createSocket('udp4'); |
|
|
const sock4 = dgram.createSocket('udp4'); |
|
|
assert(Object.getPrototypeOf(sock4._handle).hasOwnProperty('unrefed'), true); |
|
|
assert(Object.getPrototypeOf(sock4._handle).hasOwnProperty('isRefed'), true); |
|
|
assert(sock4._handle.unrefed(), false); |
|
|
assert(sock4._handle.isRefed(), true); |
|
|
sock4.unref(); |
|
|
sock4.unref(); |
|
|
assert(sock4._handle.unrefed(), true); |
|
|
assert(sock4._handle.isRefed(), false); |
|
|
sock4.ref(); |
|
|
sock4.ref(); |
|
|
assert(sock4._handle.unrefed(), false); |
|
|
assert(sock4._handle.isRefed(), true); |
|
|
sock4._handle.close( |
|
|
sock4._handle.close( |
|
|
common.mustCall(() => assert(sock4._handle.unrefed(), true))); |
|
|
common.mustCall(() => assert(sock4._handle.isRefed(), false))); |
|
|
sock4._handle.close(common.fail); |
|
|
|
|
|
assert(sock4._handle.unrefed(), false); |
|
|
|
|
|
|
|
|
|
|
|
const sock6 = dgram.createSocket('udp6'); |
|
|
const sock6 = dgram.createSocket('udp6'); |
|
|
assert(Object.getPrototypeOf(sock6._handle).hasOwnProperty('unrefed'), true); |
|
|
assert(Object.getPrototypeOf(sock6._handle).hasOwnProperty('isRefed'), true); |
|
|
assert(sock6._handle.unrefed(), false); |
|
|
assert(sock6._handle.isRefed(), true); |
|
|
sock6.unref(); |
|
|
sock6.unref(); |
|
|
assert(sock6._handle.unrefed(), true); |
|
|
assert(sock6._handle.isRefed(), false); |
|
|
sock6.ref(); |
|
|
sock6.ref(); |
|
|
assert(sock6._handle.unrefed(), false); |
|
|
assert(sock6._handle.isRefed(), true); |
|
|
sock6._handle.close( |
|
|
sock6._handle.close( |
|
|
common.mustCall(() => assert(sock6._handle.unrefed(), true))); |
|
|
common.mustCall(() => assert(sock6._handle.isRefed(), false))); |
|
|
sock6._handle.close(common.fail); |
|
|
|
|
|
assert(sock6._handle.unrefed(), false); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pipe
|
|
|
// pipe
|
|
|
{ |
|
|
{ |
|
|
const assert = makeAssert('unrefed() not working on pipe_wrap'); |
|
|
const assert = makeAssert('isRefed() not working on pipe_wrap'); |
|
|
const Pipe = process.binding('pipe_wrap').Pipe; |
|
|
const Pipe = process.binding('pipe_wrap').Pipe; |
|
|
const handle = new Pipe(); |
|
|
const handle = new Pipe(); |
|
|
assert(Object.getPrototypeOf(handle).hasOwnProperty('unrefed'), true); |
|
|
assert(Object.getPrototypeOf(handle).hasOwnProperty('isRefed'), true); |
|
|
assert(handle.unrefed(), false); |
|
|
assert(handle.isRefed(), true); |
|
|
handle.unref(); |
|
|
handle.unref(); |
|
|
assert(handle.unrefed(), true); |
|
|
assert(handle.isRefed(), false); |
|
|
handle.ref(); |
|
|
handle.ref(); |
|
|
assert(handle.unrefed(), false); |
|
|
assert(handle.isRefed(), true); |
|
|
handle.close(common.mustCall(() => assert(handle.unrefed(), true))); |
|
|
handle.close(common.mustCall(() => assert(handle.isRefed(), false))); |
|
|
handle.close(common.fail); |
|
|
|
|
|
assert(handle.unrefed(), false); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tcp
|
|
|
// tcp
|
|
|
{ |
|
|
{ |
|
|
const assert = makeAssert('unrefed() not working on tcp_wrap'); |
|
|
const assert = makeAssert('isRefed() not working on tcp_wrap'); |
|
|
const net = require('net'); |
|
|
const net = require('net'); |
|
|
const server = net.createServer(() => {}).listen(common.PORT); |
|
|
const server = net.createServer(() => {}).listen(common.PORT); |
|
|
assert(Object.getPrototypeOf(server._handle).hasOwnProperty('unrefed'), true); |
|
|
assert(Object.getPrototypeOf(server._handle).hasOwnProperty('isRefed'), true); |
|
|
assert(server._handle.unrefed(), false); |
|
|
assert(server._handle.isRefed(), true); |
|
|
assert(server._unref, false); |
|
|
assert(server._unref, false); |
|
|
server.unref(); |
|
|
server.unref(); |
|
|
assert(server._handle.unrefed(), true); |
|
|
assert(server._handle.isRefed(), false); |
|
|
assert(server._unref, true); |
|
|
assert(server._unref, true); |
|
|
server.ref(); |
|
|
server.ref(); |
|
|
assert(server._handle.unrefed(), false); |
|
|
assert(server._handle.isRefed(), true); |
|
|
assert(server._unref, false); |
|
|
assert(server._unref, false); |
|
|
server._handle.close( |
|
|
server._handle.close( |
|
|
common.mustCall(() => assert(server._handle.unrefed(), true))); |
|
|
common.mustCall(() => assert(server._handle.isRefed(), false))); |
|
|
server._handle.close(common.fail); |
|
|
|
|
|
assert(server._handle.unrefed(), false); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// timers
|
|
|
// timers
|
|
|
{ |
|
|
{ |
|
|
const assert = makeAssert('unrefed() not working on timer_wrap'); |
|
|
const assert = makeAssert('isRefed() not working on timer_wrap'); |
|
|
const timer = setTimeout(() => {}, 500); |
|
|
const timer = setTimeout(() => {}, 500); |
|
|
timer.unref(); |
|
|
timer.unref(); |
|
|
assert(Object.getPrototypeOf(timer._handle).hasOwnProperty('unrefed'), true); |
|
|
assert(Object.getPrototypeOf(timer._handle).hasOwnProperty('isRefed'), true); |
|
|
assert(timer._handle.unrefed(), true); |
|
|
assert(timer._handle.isRefed(), false); |
|
|
timer.ref(); |
|
|
timer.ref(); |
|
|
assert(timer._handle.unrefed(), false); |
|
|
assert(timer._handle.isRefed(), true); |
|
|
timer._handle.close( |
|
|
timer._handle.close( |
|
|
common.mustCall(() => assert(timer._handle.unrefed(), true))); |
|
|
common.mustCall(() => assert(timer._handle.isRefed(), false))); |
|
|
timer._handle.close(common.fail); |
|
|
|
|
|
assert(timer._handle.unrefed(), false); |
|
|
|
|
|
} |
|
|
} |
|
|