Deleted Added
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_main.h>

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

548 }
549
550 if (!engine->event.signal_support) {
551 nxt_event_engine_signals_stop(engine);
552 }
553
554 nxt_runtime_process_each(rt, process) {
555
556 nxt_runtime_process_remove(rt, process);
557
558 } nxt_runtime_process_loop;
559
560 nxt_thread_mutex_destroy(&rt->processes_mutex);
561
562 nxt_mp_destroy(rt->mem_pool);
563
564 nxt_debug(task, "exit");

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

1720
1721 nxt_thread_mutex_unlock(&rt->processes_mutex);
1722
1723 return process;
1724}
1725
1726
1727void
1728nxt_runtime_process_add(nxt_runtime_t *rt, nxt_process_t *process)
1729{
1730 nxt_port_t *port;
1731 nxt_lvlhsh_query_t lhq;
1732
1733 nxt_assert(process->registered == 0);
1734
1735 nxt_runtime_process_lhq_pid(&lhq, &process->pid);
1736
1737 lhq.replace = 0;
1738 lhq.value = process;
1739 lhq.pool = rt->mem_pool;
1740
1741 nxt_thread_mutex_lock(&rt->processes_mutex);
1742

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

1748 }
1749
1750 rt->nprocesses++;
1751
1752 nxt_process_port_each(process, port) {
1753
1754 port->pid = process->pid;
1755
1756 nxt_runtime_port_add(rt, port);
1757
1758 } nxt_process_port_loop;
1759
1760 process->registered = 1;
1761
1762 nxt_thread_log_debug("process %PI added", process->pid);
1763 break;
1764

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

1804
1805 nxt_thread_mutex_unlock(&rt->processes_mutex);
1806
1807 return process;
1808}
1809
1810
1811void
1812nxt_runtime_process_remove(nxt_runtime_t *rt, nxt_process_t *process)
1813{
1814 nxt_port_t *port;
1815
1816 if (process->port_cleanups == 0) {
1817 if (process->registered == 1) {
1818 nxt_runtime_process_remove_pid(rt, process->pid);
1819 }
1820
1821 nxt_runtime_process_destroy(rt, process);
1822
1823 } else {
1824 nxt_process_port_each(process, port) {
1825
1826 nxt_runtime_port_remove(rt, port);
1827
1828 nxt_port_release(port);
1829
1830 } nxt_process_port_loop;
1831 }
1832}
1833
1834
1835nxt_process_t *
1836nxt_runtime_process_first(nxt_runtime_t *rt, nxt_lvlhsh_each_t *lhe)

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

1846nxt_port_t *
1847nxt_runtime_port_first(nxt_runtime_t *rt, nxt_lvlhsh_each_t *lhe)
1848{
1849 return nxt_port_hash_first(&rt->ports, lhe);
1850}
1851
1852
1853void
1854nxt_runtime_port_add(nxt_runtime_t *rt, nxt_port_t *port)
1855{
1856 nxt_port_hash_add(&rt->ports, port);
1857
1858 rt->port_by_type[port->type] = port;
1859}
1860
1861
1862void
1863nxt_runtime_port_remove(nxt_runtime_t *rt, nxt_port_t *port)
1864{
1865 nxt_port_hash_remove(&rt->ports, port);
1866
1867 if (rt->port_by_type[port->type] == port) {
1868 rt->port_by_type[port->type] = NULL;
1869 }
1870}
1871
1872
1873nxt_port_t *
1874nxt_runtime_port_find(nxt_runtime_t *rt, nxt_pid_t pid,
1875 nxt_port_id_t port_id)
1876{
1877 return nxt_port_hash_find(&rt->ports, pid, port_id);
1878}