nxt_router.c (1733:dab8544b5440) nxt_router.c (1754:c21309052895)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_router.h>

--- 5359 unchanged lines hidden (view full) ---

5368static void
5369nxt_router_oosm_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
5370{
5371 size_t mi;
5372 uint32_t i;
5373 nxt_bool_t ack;
5374 nxt_process_t *process;
5375 nxt_free_map_t *m;
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_router.h>

--- 5359 unchanged lines hidden (view full) ---

5368static void
5369nxt_router_oosm_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
5370{
5371 size_t mi;
5372 uint32_t i;
5373 nxt_bool_t ack;
5374 nxt_process_t *process;
5375 nxt_free_map_t *m;
5376 nxt_port_mmap_header_t *hdr;
5376 nxt_port_mmap_handler_t *mmap_handler;
5377
5378 nxt_debug(task, "oosm in %PI", msg->port_msg.pid);
5379
5380 process = nxt_runtime_process_find(task->thread->runtime,
5381 msg->port_msg.pid);
5382 if (nxt_slow_path(process == NULL)) {
5383 return;
5384 }

--- 4 unchanged lines hidden (view full) ---

5389 * To mitigate possible racing condition (when OOSM message received
5390 * after some of the memory was already freed), need to try to find
5391 * first free segment in shared memory and send ACK if found.
5392 */
5393
5394 nxt_thread_mutex_lock(&process->incoming.mutex);
5395
5396 for (i = 0; i < process->incoming.size; i++) {
5377
5378 nxt_debug(task, "oosm in %PI", msg->port_msg.pid);
5379
5380 process = nxt_runtime_process_find(task->thread->runtime,
5381 msg->port_msg.pid);
5382 if (nxt_slow_path(process == NULL)) {
5383 return;
5384 }

--- 4 unchanged lines hidden (view full) ---

5389 * To mitigate possible racing condition (when OOSM message received
5390 * after some of the memory was already freed), need to try to find
5391 * first free segment in shared memory and send ACK if found.
5392 */
5393
5394 nxt_thread_mutex_lock(&process->incoming.mutex);
5395
5396 for (i = 0; i < process->incoming.size; i++) {
5397 hdr = process->incoming.elts[i].mmap_handler->hdr;
5398 m = hdr->free_map;
5397 mmap_handler = process->incoming.elts[i].mmap_handler;
5399
5398
5399 if (nxt_slow_path(mmap_handler == NULL)) {
5400 continue;
5401 }
5402
5403 m = mmap_handler->hdr->free_map;
5404
5400 for (mi = 0; mi < MAX_FREE_IDX; mi++) {
5401 if (m[mi] != 0) {
5402 ack = 1;
5403
5404 nxt_debug(task, "oosm: already free #%uD %uz = 0x%08xA",
5405 i, mi, m[mi]);
5406
5407 break;

--- 127 unchanged lines hidden ---
5405 for (mi = 0; mi < MAX_FREE_IDX; mi++) {
5406 if (m[mi] != 0) {
5407 ack = 1;
5408
5409 nxt_debug(task, "oosm: already free #%uD %uz = 0x%08xA",
5410 i, mi, m[mi]);
5411
5412 break;

--- 127 unchanged lines hidden ---