Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/nxt_port_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,13 @@ nxt_port_read_handler(nxt_task_t *task, void *obj, void *data)
b = nxt_port_buf_alloc(port);

if (nxt_slow_path(b == NULL)) {
/* TODO: disable event for some time */
nxt_log(task, NXT_LOG_INFO,
"port{%d,%d} %d: read-buf alloc failed; "
"blocking read event",
(int) port->pid, (int) port->id, port->socket.fd);

nxt_fd_event_block_read(task->thread->engine, &port->socket);
return;
}

iov[0].iov_base = &msg.port_msg;
Expand Down Expand Up @@ -889,7 +895,14 @@ nxt_port_queue_read_handler(nxt_task_t *task, void *obj, void *data)
b = nxt_port_buf_alloc(port);

if (nxt_slow_path(b == NULL)) {
/* TODO: disable event for some time */
nxt_log(task, NXT_LOG_INFO,
"port{%d,%d} %d: read-buf alloc failed; "
"blocking queue read event",
(int) port->pid, (int) port->id, port->socket.fd);

nxt_atomic_fetch_add(&queue->nitems, -1);
nxt_fd_event_block_read(task->thread->engine, &port->socket);
return;
}
Comment on lines 897 to 906
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In nxt_port_queue_read_handler, if nxt_port_buf_alloc(port) fails at line 895, any message already dequeued from the shared memory queue at line 841 (via nxt_port_queue_recv) will be lost. This is because the message data is currently held only in the local qmsg buffer, which is discarded when the function returns. To avoid losing IPC messages during memory pressure, consider allocating the buffer before consuming the message from the shared queue. Additionally, using NXT_LOG_INFO for a condition that effectively halts IPC for the process might be too low; NXT_LOG_WARN or NXT_LOG_ERR would be more appropriate to signal the severity of the resource exhaustion.


if (n >= (ssize_t) sizeof(nxt_port_msg_t)) {
Expand Down Expand Up @@ -1342,7 +1355,6 @@ nxt_port_error_handler(nxt_task_t *task, void *obj, void *data)
nxt_port_send_msg_t *msg;

nxt_debug(task, "port error handler %p", obj);
/* TODO */

port = nxt_container_of(obj, nxt_port_t, socket);

Expand Down
Loading