nxt_runtime.c (326:2aad6a5fac13) nxt_runtime.c (341:5e1a9c009968)
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>

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

1581
1582 return process;
1583}
1584
1585
1586static void
1587nxt_runtime_process_destroy(nxt_runtime_t *rt, nxt_process_t *process)
1588{
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>

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

1581
1582 return process;
1583}
1584
1585
1586static void
1587nxt_runtime_process_destroy(nxt_runtime_t *rt, nxt_process_t *process)
1588{
1589 nxt_port_t *port;
1590 nxt_lvlhsh_each_t lhe;
1591
1589 nxt_assert(process->port_cleanups == 0);
1590 nxt_assert(process->registered == 0);
1591
1592 nxt_port_mmaps_destroy(process->incoming, 1);
1593 nxt_port_mmaps_destroy(process->outgoing, 1);
1594
1592 nxt_assert(process->port_cleanups == 0);
1593 nxt_assert(process->registered == 0);
1594
1595 nxt_port_mmaps_destroy(process->incoming, 1);
1596 nxt_port_mmaps_destroy(process->outgoing, 1);
1597
1595 if (process->cp_mem_pool != NULL) {
1596 nxt_mp_thread_adopt(process->cp_mem_pool);
1598 port = nxt_port_hash_first(&process->connected_ports, &lhe);
1597
1599
1598 nxt_mp_destroy(process->cp_mem_pool);
1600 while(port != NULL) {
1601 nxt_port_hash_remove(&process->connected_ports, port);
1602
1603 port = nxt_port_hash_first(&process->connected_ports, &lhe);
1599 }
1600
1601 nxt_thread_mutex_destroy(&process->incoming_mutex);
1602 nxt_thread_mutex_destroy(&process->outgoing_mutex);
1603 nxt_thread_mutex_destroy(&process->cp_mutex);
1604
1605 nxt_mp_free(rt->mem_pool, process);
1606}

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

1842{
1843 return nxt_port_hash_first(&rt->ports, lhe);
1844}
1845
1846
1847void
1848nxt_runtime_port_add(nxt_runtime_t *rt, nxt_port_t *port)
1849{
1604 }
1605
1606 nxt_thread_mutex_destroy(&process->incoming_mutex);
1607 nxt_thread_mutex_destroy(&process->outgoing_mutex);
1608 nxt_thread_mutex_destroy(&process->cp_mutex);
1609
1610 nxt_mp_free(rt->mem_pool, process);
1611}

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

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