Go: fixing racing condition on app start.
Request procesing loop should be started in ready handler to avoid race between go-routine start and context ready flag assignment. The issue introduced in 43553aa72111.
This commit is contained in:
@@ -30,6 +30,7 @@ nxt_cgo_run(uintptr_t handler)
|
|||||||
init.callbacks.port_send = nxt_cgo_port_send;
|
init.callbacks.port_send = nxt_cgo_port_send;
|
||||||
init.callbacks.port_recv = nxt_cgo_port_recv;
|
init.callbacks.port_recv = nxt_cgo_port_recv;
|
||||||
init.callbacks.shm_ack_handler = nxt_go_shm_ack_handler;
|
init.callbacks.shm_ack_handler = nxt_go_shm_ack_handler;
|
||||||
|
init.callbacks.ready_handler = nxt_go_ready;
|
||||||
|
|
||||||
init.data = (void *) handler;
|
init.data = (void *) handler;
|
||||||
|
|
||||||
|
|||||||
11
go/port.go
11
go/port.go
@@ -110,12 +110,15 @@ func nxt_go_add_port(ctx *C.nxt_unit_ctx_t, p *C.nxt_unit_port_t) C.int {
|
|||||||
p.in_fd = -1
|
p.in_fd = -1
|
||||||
p.out_fd = -1
|
p.out_fd = -1
|
||||||
|
|
||||||
if new_port.key.id == 65535 {
|
return C.NXT_UNIT_OK
|
||||||
go func(ctx *C.nxt_unit_ctx_t) {
|
|
||||||
C.nxt_unit_run_shared(ctx);
|
|
||||||
}(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export nxt_go_ready
|
||||||
|
func nxt_go_ready(ctx *C.nxt_unit_ctx_t) C.int {
|
||||||
|
go func(ctx *C.nxt_unit_ctx_t) {
|
||||||
|
C.nxt_unit_run_shared(ctx)
|
||||||
|
}(ctx)
|
||||||
|
|
||||||
return C.NXT_UNIT_OK
|
return C.NXT_UNIT_OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user