nxt_process.c (320:d385755599d6) nxt_process.c (341:5e1a9c009968)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_main_process.h>

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

614}
615
616
617void
618nxt_process_connected_port_add(nxt_process_t *process, nxt_port_t *port)
619{
620 nxt_thread_mutex_lock(&process->cp_mutex);
621
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_main_process.h>

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

614}
615
616
617void
618nxt_process_connected_port_add(nxt_process_t *process, nxt_port_t *port)
619{
620 nxt_thread_mutex_lock(&process->cp_mutex);
621
622 if (process->cp_mem_pool == NULL) {
623 process->cp_mem_pool = nxt_mp_create(1024, 128, 256, 32);
624 }
622 nxt_port_hash_add(&process->connected_ports, port);
625
623
626 nxt_mp_thread_adopt(process->cp_mem_pool);
627
628 nxt_port_hash_add(&process->connected_ports, process->cp_mem_pool, port);
629
630 nxt_thread_mutex_unlock(&process->cp_mutex);
631}
632
633void
634nxt_process_connected_port_remove(nxt_process_t *process, nxt_port_t *port)
635{
636 nxt_thread_mutex_lock(&process->cp_mutex);
637
624 nxt_thread_mutex_unlock(&process->cp_mutex);
625}
626
627void
628nxt_process_connected_port_remove(nxt_process_t *process, nxt_port_t *port)
629{
630 nxt_thread_mutex_lock(&process->cp_mutex);
631
638 if (process->cp_mem_pool != NULL) {
639 nxt_mp_thread_adopt(process->cp_mem_pool);
632 nxt_port_hash_remove(&process->connected_ports, port);
640
633
641 nxt_port_hash_remove(&process->connected_ports, process->cp_mem_pool,
642 port);
643 }
644
645 nxt_thread_mutex_unlock(&process->cp_mutex);
646}
647
648nxt_port_t *
649nxt_process_connected_port_find(nxt_process_t *process, nxt_pid_t pid,
650 nxt_port_id_t port_id)
651{
652 nxt_port_t *res;
653
654 nxt_thread_mutex_lock(&process->cp_mutex);
655
656 res = nxt_port_hash_find(&process->connected_ports, pid, port_id);
657
658 nxt_thread_mutex_unlock(&process->cp_mutex);
659
660 return res;
661}
634 nxt_thread_mutex_unlock(&process->cp_mutex);
635}
636
637nxt_port_t *
638nxt_process_connected_port_find(nxt_process_t *process, nxt_pid_t pid,
639 nxt_port_id_t port_id)
640{
641 nxt_port_t *res;
642
643 nxt_thread_mutex_lock(&process->cp_mutex);
644
645 res = nxt_port_hash_find(&process->connected_ports, pid, port_id);
646
647 nxt_thread_mutex_unlock(&process->cp_mutex);
648
649 return res;
650}