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.
This commit is contained in:
@@ -26,6 +26,7 @@ struct nxt_port_handlers_s {
|
||||
nxt_port_handler_t change_file;
|
||||
nxt_port_handler_t new_port;
|
||||
nxt_port_handler_t get_port;
|
||||
nxt_port_handler_t port_ack;
|
||||
nxt_port_handler_t mmap;
|
||||
nxt_port_handler_t get_mmap;
|
||||
|
||||
@@ -84,6 +85,7 @@ typedef enum {
|
||||
_NXT_PORT_MSG_CHANGE_FILE = nxt_port_handler_idx(change_file),
|
||||
_NXT_PORT_MSG_NEW_PORT = nxt_port_handler_idx(new_port),
|
||||
_NXT_PORT_MSG_GET_PORT = nxt_port_handler_idx(get_port),
|
||||
_NXT_PORT_MSG_PORT_ACK = nxt_port_handler_idx(port_ack),
|
||||
_NXT_PORT_MSG_MMAP = nxt_port_handler_idx(mmap),
|
||||
_NXT_PORT_MSG_GET_MMAP = nxt_port_handler_idx(get_mmap),
|
||||
|
||||
@@ -120,6 +122,7 @@ typedef enum {
|
||||
NXT_PORT_MSG_CHANGE_FILE = nxt_msg_last(_NXT_PORT_MSG_CHANGE_FILE),
|
||||
NXT_PORT_MSG_NEW_PORT = nxt_msg_last(_NXT_PORT_MSG_NEW_PORT),
|
||||
NXT_PORT_MSG_GET_PORT = nxt_msg_last(_NXT_PORT_MSG_GET_PORT),
|
||||
NXT_PORT_MSG_PORT_ACK = nxt_msg_last(_NXT_PORT_MSG_PORT_ACK),
|
||||
NXT_PORT_MSG_MMAP = nxt_msg_last(_NXT_PORT_MSG_MMAP)
|
||||
| NXT_PORT_MSG_SYNC,
|
||||
NXT_PORT_MSG_GET_MMAP = nxt_msg_last(_NXT_PORT_MSG_GET_MMAP),
|
||||
|
||||
Reference in New Issue
Block a user