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.
This commit is contained in:
@@ -44,7 +44,7 @@ nxt_cgo_run(uintptr_t handler)
|
||||
return NXT_UNIT_ERROR;
|
||||
}
|
||||
|
||||
rc = nxt_unit_run(ctx);
|
||||
rc = nxt_unit_run_ctx(ctx);
|
||||
|
||||
nxt_unit_done(ctx);
|
||||
|
||||
@@ -105,7 +105,7 @@ 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 *ctx, nxt_unit_port_t *port)
|
||||
{
|
||||
nxt_go_add_port(port->id.pid, port->id.id,
|
||||
nxt_go_add_port((uintptr_t) ctx, port->id.pid, port->id.id,
|
||||
port->in_fd, port->out_fd);
|
||||
|
||||
port->in_fd = -1;
|
||||
@@ -203,6 +203,13 @@ nxt_cgo_request_done(uintptr_t req, int res)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nxt_cgo_unit_run_shared(uintptr_t ctx)
|
||||
{
|
||||
nxt_unit_run_shared((nxt_unit_ctx_t *) ctx);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nxt_cgo_warn(uintptr_t msg, uint32_t msg_len)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,8 @@ int nxt_cgo_request_close(uintptr_t req);
|
||||
|
||||
void nxt_cgo_request_done(uintptr_t req, int res);
|
||||
|
||||
void nxt_cgo_unit_run_shared(uintptr_t ctx);
|
||||
|
||||
void nxt_cgo_warn(uintptr_t msg, uint32_t msg_len);
|
||||
|
||||
#endif /* _NXT_CGO_LIB_H_INCLUDED_ */
|
||||
|
||||
@@ -93,7 +93,7 @@ func getUnixConn(fd int) *net.UnixConn {
|
||||
}
|
||||
|
||||
//export nxt_go_add_port
|
||||
func nxt_go_add_port(pid C.int, id C.int, rcv C.int, snd C.int) {
|
||||
func nxt_go_add_port(ctx C.uintptr_t, pid C.int, id C.int, rcv C.int, snd C.int) {
|
||||
p := &port{
|
||||
key: port_key{
|
||||
pid: int(pid),
|
||||
@@ -104,6 +104,12 @@ func nxt_go_add_port(pid C.int, id C.int, rcv C.int, snd C.int) {
|
||||
}
|
||||
|
||||
add_port(p)
|
||||
|
||||
if id == 65535 {
|
||||
go func(ctx C.uintptr_t) {
|
||||
C.nxt_cgo_unit_run_shared(ctx);
|
||||
}(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
//export nxt_go_remove_port
|
||||
|
||||
Reference in New Issue
Block a user