MCPcopy
hub / github.com/plasma-umass/browsix / rr

Function rr

node/lib/cluster.js:586–638  ·  view source on GitHub ↗
(message, cb)

Source from the content-addressed store, hash-verified

584
585 // Round-robin. Master distributes handles across workers.
586 function rr(message, cb) {
587 if (message.errno)
588 return cb(message.errno, null);
589
590 var key = message.key;
591 function listen(backlog) {
592 // TODO(bnoordhuis) Send a message to the master that tells it to
593 // update the backlog size. The actual backlog should probably be
594 // the largest requested size by any worker.
595 return 0;
596 }
597
598 function close() {
599 // lib/net.js treats server._handle.close() as effectively synchronous.
600 // That means there is a time window between the call to close() and
601 // the ack by the master process in which we can still receive handles.
602 // onconnection() below handles that by sending those handles back to
603 // the master.
604 if (key === undefined) return;
605 send({ act: 'close', key: key });
606 delete handles[key];
607 key = undefined;
608 }
609
610 function getsockname(out) {
611 if (key) util._extend(out, message.sockname);
612 return 0;
613 }
614
615 // XXX(bnoordhuis) Probably no point in implementing ref() and unref()
616 // because the control channel is going to keep the worker alive anyway.
617 function ref() {
618 }
619
620 function unref() {
621 }
622
623 // Faux handle. Mimics a TCPWrap with just enough fidelity to get away
624 // with it. Fools net.Server into thinking that it's backed by a real
625 // handle.
626 var handle = {
627 close: close,
628 listen: listen,
629 ref: ref,
630 unref: unref,
631 };
632 if (message.sockname) {
633 handle.getsockname = getsockname; // TCP handles only.
634 }
635 assert(handles[key] === undefined);
636 handles[key] = handle;
637 cb(0, handle);
638 }
639
640 // Round-robin connection.
641 function onconnection(message, handle) {

Callers 1

workerInitFunction · 0.85

Calls 2

cbFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected