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);
556 nxt_runtime_process_remove(task, 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)
1728nxt_runtime_process_add(nxt_task_t *task, nxt_process_t *process)
1729{
1730 nxt_port_t *port;
1731 nxt_runtime_t *rt;
1732 nxt_lvlhsh_query_t lhq;
1733
1734 nxt_assert(process->registered == 0);
1735
1736 rt = task->thread->runtime;
1737
1738 nxt_runtime_process_lhq_pid(&lhq, &process->pid);
1739
1740 lhq.replace = 0;
1741 lhq.value = process;
1742 lhq.pool = rt->mem_pool;
1743
1744 nxt_thread_mutex_lock(&rt->processes_mutex);
1745

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

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

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

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

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

1852nxt_port_t *
1853nxt_runtime_port_first(nxt_runtime_t *rt, nxt_lvlhsh_each_t *lhe)
1854{
1855 return nxt_port_hash_first(&rt->ports, lhe);
1856}
1857
1858
1859void
1854nxt_runtime_port_add(nxt_runtime_t *rt, nxt_port_t *port)
1860nxt_runtime_port_add(nxt_task_t *task, nxt_port_t *port)
1861{
1862 nxt_runtime_t *rt;
1863
1864 rt = task->thread->runtime;
1865
1866 nxt_port_hash_add(&rt->ports, port);
1867
1868 rt->port_by_type[port->type] = port;
1869
1870 nxt_port_use(task, port, 1);
1871}
1872
1873
1874void
1863nxt_runtime_port_remove(nxt_runtime_t *rt, nxt_port_t *port)
1875nxt_runtime_port_remove(nxt_task_t *task, nxt_port_t *port)
1876{
1877 nxt_runtime_t *rt;
1878
1879 rt = task->thread->runtime;
1880
1881 nxt_port_hash_remove(&rt->ports, port);
1882
1883 if (rt->port_by_type[port->type] == port) {
1884 rt->port_by_type[port->type] = NULL;
1885 }
1886
1887 nxt_port_use(task, port, -1);
1888}
1889
1890
1891nxt_port_t *
1892nxt_runtime_port_find(nxt_runtime_t *rt, nxt_pid_t pid,
1893 nxt_port_id_t port_id)
1894{
1895 return nxt_port_hash_find(&rt->ports, pid, port_id);
1896}