From 28ab1de364d048a4cb3f92179adebdd1eb851d65 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 28 Oct 2020 00:01:46 +0300 Subject: Libunit: gracefully quitting a multicontext application. --- src/nxt_unit.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nxt_unit.h') diff --git a/src/nxt_unit.h b/src/nxt_unit.h index e90f0781..52f9bc27 100644 --- a/src/nxt_unit.h +++ b/src/nxt_unit.h @@ -34,6 +34,8 @@ enum { #define NXT_UNIT_INIT_ENV "NXT_UNIT_INIT" +#define NXT_UNIT_SHARED_PORT_ID ((uint16_t) 0xFFFFu) + /* * Mostly opaque structure with library state. * -- cgit From a5508cec7a55fe04ab66451c7510fab0e0d4577c Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 28 Oct 2020 00:01:46 +0300 Subject: Libunit: added a function to discern main and worker contexts. --- src/nxt_unit.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nxt_unit.h') diff --git a/src/nxt_unit.h b/src/nxt_unit.h index 52f9bc27..303d5aa1 100644 --- a/src/nxt_unit.h +++ b/src/nxt_unit.h @@ -210,6 +210,8 @@ int nxt_unit_run_ctx(nxt_unit_ctx_t *ctx); int nxt_unit_run_shared(nxt_unit_ctx_t *ctx); +int nxt_unit_is_main_ctx(nxt_unit_ctx_t *ctx); + /* * Receive and process one message, invoke configured callbacks. * -- cgit From 4cb8aeb31a8cf47f6c61aaccb95bbbf47cbc2393 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 28 Oct 2020 00:01:46 +0300 Subject: Router: introducing the PORT_ACK message. The PORT_ACK message is the router's response to the application's NEW_PORT message. After receiving PORT_ACK, the application is safe to process requests using this port. This message avoids a racing condition when the application starts processing a request from the shared queue and sends REQ_HEADERS_ACK. The REQ_HEADERS_ACK message contains the application port ID as reply_port, which the router uses to send request data. When the application creates a new port, it immediately sends it to the main router thread. Because the request is processed outside the main thread, a racing condition can occur between the receipt of the new port in the main thread and the receipt of REQ_HEADERS_ACK in the worker router thread where the same port is specified as reply_port. --- src/nxt_unit.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nxt_unit.h') diff --git a/src/nxt_unit.h b/src/nxt_unit.h index 303d5aa1..cb78e862 100644 --- a/src/nxt_unit.h +++ b/src/nxt_unit.h @@ -154,6 +154,8 @@ struct nxt_unit_callbacks_s { /* Receive data on port id. Optional. */ ssize_t (*port_recv)(nxt_unit_ctx_t *, nxt_unit_port_t *port, void *buf, size_t buf_size, void *oob, size_t oob_size); + + int (*ready_handler)(nxt_unit_ctx_t *); }; -- cgit From 8340ca0b9c7ad4109033ccb028f87cc1b73396bc Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 18 Nov 2020 22:33:53 +0300 Subject: Libunit: improving logging consistency. Debug logging depends on macros defined in nxt_auto_config.h. --- src/nxt_unit.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nxt_unit.h') diff --git a/src/nxt_unit.h b/src/nxt_unit.h index cb78e862..90cba2a3 100644 --- a/src/nxt_unit.h +++ b/src/nxt_unit.h @@ -12,6 +12,7 @@ #include #include +#include "nxt_auto_config.h" #include "nxt_version.h" #include "nxt_unit_typedefs.h" -- cgit From 8132e1f700934a32bc9e3fb0ab66f550a335a326 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 18 Nov 2020 22:33:53 +0300 Subject: Go: removing C proxy functions and re-using goroutines. --- src/nxt_unit.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nxt_unit.h') diff --git a/src/nxt_unit.h b/src/nxt_unit.h index 90cba2a3..1e1a8dbe 100644 --- a/src/nxt_unit.h +++ b/src/nxt_unit.h @@ -213,6 +213,8 @@ int nxt_unit_run_ctx(nxt_unit_ctx_t *ctx); int nxt_unit_run_shared(nxt_unit_ctx_t *ctx); +nxt_unit_request_info_t *nxt_unit_dequeue_request(nxt_unit_ctx_t *ctx); + int nxt_unit_is_main_ctx(nxt_unit_ctx_t *ctx); /* -- cgit