GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: dynamic port in cluster worker send · nodejs/node@ce3b544

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-cluster-send-deadlock.js
    • test-cluster-send-handle-twice.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-cluster-send-deadlock.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-send-deadlock.js
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Testing mutual send of handles: from master to worker, and from worker to
33
// master.
44

5-
const common = require('../common');
5+
require('../common');
66
const assert = require('assert');
77
const cluster = require('cluster');
88
const net = require('net');
@@ -19,14 +19,15 @@ if (cluster.isMaster) {
1919
worker.send('handle', socket);
2020
});
2121

22-
server.listen(common.PORT, function() {
23-
worker.send('listen');
22+
server.listen(0, function() {
23+
worker.send({message: 'listen', port: server.address().port});
2424
});
2525
} else {
2626
process.on('message', function(msg, handle) {
27-
if (msg === 'listen') {
28-
const client1 = net.connect({ host: 'localhost', port: common.PORT });
29-
const client2 = net.connect({ host: 'localhost', port: common.PORT });
27+
if (msg.message && msg.message === 'listen') {
28+
assert(msg.port);
29+
const client1 = net.connect({ host: 'localhost', port: msg.port });
30+
const client2 = net.connect({ host: 'localhost', port: msg.port });
3031
let waiting = 2;
3132
client1.on('close', onclose);
3233
client2.on('close', onclose);
Collapse file

‎test/parallel/test-cluster-send-handle-twice.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-send-handle-twice.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ if (cluster.isMaster) {
2424
process.send('send-handle-2', socket);
2525
});
2626

27-
server.listen(common.PORT, function() {
28-
const client = net.connect({ host: 'localhost', port: common.PORT });
27+
server.listen(0, function() {
28+
const client = net.connect({
29+
host: 'localhost',
30+
port: server.address().port
31+
});
2932
client.on('close', common.mustCall(() => { cluster.worker.disconnect(); }));
3033
setTimeout(function() { client.end(); }, 50);
3134
}).on('error', function(e) {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.