RPC: peer pid special value -1 may be used if pid is unknown.
@@ -107,7 +107,7 @@ nxt_port_rpc_register_handler(nxt_task_t *task, nxt_port_t *port,
return 0;
}
-
+ if (peer != -1) {
nxt_port_rpc_lhq_peer(&lhq, &peer);
lhq.replace = 0;
lhq.value = &reg->link;
@@ -129,6 +129,7 @@ nxt_port_rpc_register_handler(nxt_task_t *task, nxt_port_t *port,
"for stream #%uD", stream);
break;
}
+ }
return stream;
}
@@ -169,7 +170,9 @@ nxt_port_rpc_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
reg = lhq.value;
+ if (reg->peer != -1) {
nxt_assert(reg->peer == msg->port_msg.pid);
+ }
if (type == _NXT_PORT_MSG_RPC_ERROR) {
reg->error_handler(task, msg, reg->data);
@@ -183,6 +186,7 @@ nxt_port_rpc_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
return;
}
+ if (reg->peer != -1) {
if (reg->link.next == &reg->link) {
nxt_port_rpc_lhq_peer(&lhq, &reg->peer);
lhq.pool = port->mem_pool;
@@ -196,6 +200,7 @@ nxt_port_rpc_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
} else {
nxt_queue_remove(&reg->link);
}
+ }
nxt_mp_free(port->mem_pool, reg);
}
@@ -296,6 +301,7 @@ nxt_port_rpc_cancel(nxt_task_t *task, nxt_port_t *port, uint32_t stream)
reg = lhq.value;
+ if (reg->peer != -1) {
if (reg->link.next == &reg->link) {
nxt_port_rpc_lhq_peer(&lhq, &reg->peer);
lhq.pool = port->mem_pool;
@@ -309,6 +315,7 @@ nxt_port_rpc_cancel(nxt_task_t *task, nxt_port_t *port, uint32_t stream)
} else {
nxt_queue_remove(&reg->link);
}
+ }
nxt_mp_free(port->mem_pool, reg);
}
