summaryrefslogtreecommitdiffhomepage
path: root/go
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-08-11 19:19:55 +0300
committerMax Romanov <max.romanov@nginx.com>2020-08-11 19:19:55 +0300
commitec3389b63bd7a9159d2be4a2863140f75095c7d3 (patch)
treef88972c19c713748b56c339dab1bdd60892eaeec /go
parent3a721e1d96720505d4d6638e77d2c296d962519c (diff)
downloadunit-ec3389b63bd7a9159d2be4a2863140f75095c7d3.tar.gz
unit-ec3389b63bd7a9159d2be4a2863140f75095c7d3.tar.bz2
Libunit refactoring: port management.
- Changed the port management callbacks to notifications, which e. g. avoids the need to call the libunit function - Added context and library instance reference counts for a safer resource release - Added the router main port initialization
Diffstat (limited to 'go')
-rw-r--r--go/nxt_cgo_lib.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/go/nxt_cgo_lib.c b/go/nxt_cgo_lib.c
index a4fef9ea..1bb38f3c 100644
--- a/go/nxt_cgo_lib.c
+++ b/go/nxt_cgo_lib.c
@@ -14,7 +14,7 @@ static void nxt_cgo_request_handler(nxt_unit_request_info_t *req);
static nxt_cgo_str_t *nxt_cgo_str_init(nxt_cgo_str_t *dst,
nxt_unit_sptr_t *sptr, uint32_t length);
static int nxt_cgo_add_port(nxt_unit_ctx_t *, nxt_unit_port_t *port);
-static void nxt_cgo_remove_port(nxt_unit_ctx_t *, nxt_unit_port_id_t *port_id);
+static void nxt_cgo_remove_port(nxt_unit_t *, nxt_unit_port_t *port);
static ssize_t nxt_cgo_port_send(nxt_unit_ctx_t *, nxt_unit_port_id_t *port_id,
const void *buf, size_t buf_size, const void *oob, size_t oob_size);
static ssize_t nxt_cgo_port_recv(nxt_unit_ctx_t *, nxt_unit_port_id_t *port_id,
@@ -108,16 +108,17 @@ nxt_cgo_add_port(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port)
nxt_go_add_port(port->id.pid, port->id.id,
port->in_fd, port->out_fd);
- return nxt_unit_add_port(ctx, port);
+ port->in_fd = -1;
+ port->out_fd = -1;
+
+ return NXT_UNIT_OK;
}
static void
-nxt_cgo_remove_port(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id)
+nxt_cgo_remove_port(nxt_unit_t *unit, nxt_unit_port_t *port)
{
- nxt_go_remove_port(port_id->pid, port_id->id);
-
- nxt_unit_remove_port(ctx, port_id);
+ nxt_go_remove_port(port->id.pid, port->id.id);
}