summaryrefslogtreecommitdiffhomepage
path: root/src/nodejs/unit-http
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-08-11 19:20:15 +0300
committerMax Romanov <max.romanov@nginx.com>2020-08-11 19:20:15 +0300
commit83595606121a821f9e3cef0f0b7e7fe87eb1e50a (patch)
tree2374867dd2f69654a71e95b7abec3fdad13ffd1a /src/nodejs/unit-http
parent6e31d6cd39be9d3f4ee680fc13c3fe42f5cd39e7 (diff)
downloadunit-83595606121a821f9e3cef0f0b7e7fe87eb1e50a.tar.gz
unit-83595606121a821f9e3cef0f0b7e7fe87eb1e50a.tar.bz2
Introducing the shared application port.
This is the port shared between all application processes which use it to pass requests for processing. Using it significantly simplifies the request processing code in the router. The drawback is 2 more file descriptors per each configured application and more complex libunit message wait/read code.
Diffstat (limited to '')
-rw-r--r--src/nodejs/unit-http/unit.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/nodejs/unit-http/unit.cpp b/src/nodejs/unit-http/unit.cpp
index 468acf96..1ee5b742 100644
--- a/src/nodejs/unit-http/unit.cpp
+++ b/src/nodejs/unit-http/unit.cpp
@@ -20,7 +20,7 @@ napi_ref Unit::constructor_;
struct port_data_t {
nxt_unit_ctx_t *ctx;
- nxt_unit_port_id_t port_id;
+ nxt_unit_port_t *port;
uv_poll_t poll;
};
@@ -351,7 +351,11 @@ Unit::shm_ack_handler(nxt_unit_ctx_t *ctx)
static void
nxt_uv_read_callback(uv_poll_t *handle, int status, int events)
{
- nxt_unit_run_once((nxt_unit_ctx_t *) handle->data);
+ port_data_t *data;
+
+ data = (port_data_t *) handle->data;
+
+ nxt_unit_process_port_msg(data->ctx, data->port);
}
@@ -396,21 +400,14 @@ Unit::add_port(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port)
port->data = data;
data->ctx = ctx;
- data->port_id = port->id;
- data->poll.data = ctx;
+ data->port = port;
+ data->poll.data = data;
}
return NXT_UNIT_OK;
}
-inline bool
-operator == (const nxt_unit_port_id_t &p1, const nxt_unit_port_id_t &p2)
-{
- return p1.pid == p2.pid && p1.id == p2.id;
-}
-
-
void
Unit::remove_port(nxt_unit_t *unit, nxt_unit_port_t *port)
{
@@ -419,10 +416,9 @@ Unit::remove_port(nxt_unit_t *unit, nxt_unit_port_t *port)
if (port->data != NULL) {
data = (port_data_t *) port->data;
- if (data->port_id == port->id) {
+ if (data->port == port) {
uv_poll_stop(&data->poll);
- data->poll.data = data;
uv_close((uv_handle_t *) &data->poll, delete_port_data);
}
}