Using engine memiory pool for port write allocations.
To allow use port from different threads, the first step is to avoid using port's memory pool for temporary allocations required to send data through the port. Including but not limited by: - buffers for data; - send message structures; - new mmap fd notifications; It is still safe to use port memory pool for incoming buffers allocations because recieve operation bound to single thread.
This commit is contained in:
@@ -769,7 +769,8 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid)
|
||||
|
||||
port = nxt_process_port_first(process);
|
||||
|
||||
buf = nxt_buf_mem_alloc(port->mem_pool, sizeof(pid), 0);
|
||||
buf = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool,
|
||||
sizeof(pid));
|
||||
buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(pid));
|
||||
|
||||
nxt_port_socket_write(task, port, NXT_PORT_MSG_REMOVE_PID,
|
||||
@@ -836,7 +837,8 @@ nxt_main_port_socket_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
|
||||
|
||||
nxt_log(task, NXT_LOG_CRIT, "%*s", size, ls.start);
|
||||
|
||||
out = nxt_buf_mem_alloc(port->mem_pool, size + 1, 0);
|
||||
out = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool,
|
||||
size + 1);
|
||||
if (nxt_slow_path(out == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user