nxt_runtime.c (343:9fa845db60fb) nxt_runtime.c (348:5342d18db890)
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>

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

1854{
1855 return nxt_port_hash_first(&rt->ports, lhe);
1856}
1857
1858
1859void
1860nxt_runtime_port_add(nxt_task_t *task, nxt_port_t *port)
1861{
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>

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

1854{
1855 return nxt_port_hash_first(&rt->ports, lhe);
1856}
1857
1858
1859void
1860nxt_runtime_port_add(nxt_task_t *task, nxt_port_t *port)
1861{
1862 nxt_int_t res;
1862 nxt_runtime_t *rt;
1863
1864 rt = task->thread->runtime;
1865
1863 nxt_runtime_t *rt;
1864
1865 rt = task->thread->runtime;
1866
1866 nxt_port_hash_add(&rt->ports, port);
1867 res = nxt_port_hash_add(&rt->ports, port);
1867
1868
1869 if (res != NXT_OK) {
1870 return;
1871 }
1872
1868 rt->port_by_type[port->type] = port;
1869
1870 nxt_port_use(task, port, 1);
1871}
1872
1873
1874void
1875nxt_runtime_port_remove(nxt_task_t *task, nxt_port_t *port)
1876{
1873 rt->port_by_type[port->type] = port;
1874
1875 nxt_port_use(task, port, 1);
1876}
1877
1878
1879void
1880nxt_runtime_port_remove(nxt_task_t *task, nxt_port_t *port)
1881{
1882 nxt_int_t res;
1877 nxt_runtime_t *rt;
1878
1879 rt = task->thread->runtime;
1880
1883 nxt_runtime_t *rt;
1884
1885 rt = task->thread->runtime;
1886
1881 nxt_port_hash_remove(&rt->ports, port);
1887 res = nxt_port_hash_remove(&rt->ports, port);
1882
1888
1889 if (res != NXT_OK) {
1890 return;
1891 }
1892
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}
1893 if (rt->port_by_type[port->type] == port) {
1894 rt->port_by_type[port->type] = NULL;
1895 }
1896
1897 nxt_port_use(task, port, -1);
1898}
1899
1900
1901nxt_port_t *
1902nxt_runtime_port_find(nxt_runtime_t *rt, nxt_pid_t pid,
1903 nxt_port_id_t port_id)
1904{
1905 return nxt_port_hash_find(&rt->ports, pid, port_id);
1906}