Deleted
Added
nxt_port_hash.c (341:5e1a9c009968) | nxt_port_hash.c (348:5342d18db890) |
---|---|
1 2/* 3 * Copyright (C) Max Romanov 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_port_hash.h> 8 --- 49 unchanged lines hidden (view full) --- 58 lhq->key_hash = nxt_murmur_hash2(pid_port, sizeof(nxt_pid_port_id_t)); 59 lhq->key.length = sizeof(nxt_pid_port_id_t); 60 lhq->key.start = (u_char *) pid_port; 61 lhq->proto = &lvlhsh_ports_proto; 62 lhq->pool = NULL; 63} 64 65 | 1 2/* 3 * Copyright (C) Max Romanov 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_port_hash.h> 8 --- 49 unchanged lines hidden (view full) --- 58 lhq->key_hash = nxt_murmur_hash2(pid_port, sizeof(nxt_pid_port_id_t)); 59 lhq->key.length = sizeof(nxt_pid_port_id_t); 60 lhq->key.start = (u_char *) pid_port; 61 lhq->proto = &lvlhsh_ports_proto; 62 lhq->pool = NULL; 63} 64 65 |
66void | 66nxt_int_t |
67nxt_port_hash_add(nxt_lvlhsh_t *port_hash, nxt_port_t *port) 68{ | 67nxt_port_hash_add(nxt_lvlhsh_t *port_hash, nxt_port_t *port) 68{ |
69 nxt_int_t res; |
|
69 nxt_pid_port_id_t pid_port; 70 nxt_lvlhsh_query_t lhq; 71 72 pid_port.pid = port->pid; 73 pid_port.port_id = port->id; 74 75 nxt_port_hash_lhq(&lhq, &pid_port); 76 lhq.replace = 0; 77 lhq.value = port; 78 | 70 nxt_pid_port_id_t pid_port; 71 nxt_lvlhsh_query_t lhq; 72 73 pid_port.pid = port->pid; 74 pid_port.port_id = port->id; 75 76 nxt_port_hash_lhq(&lhq, &pid_port); 77 lhq.replace = 0; 78 lhq.value = port; 79 |
79 switch (nxt_lvlhsh_insert(port_hash, &lhq)) { | 80 res = nxt_lvlhsh_insert(port_hash, &lhq); |
80 | 81 |
82 switch (res) { 83 |
|
81 case NXT_OK: 82 break; 83 84 default: 85 nxt_thread_log_error(NXT_LOG_WARN, "port #%d for pid %PI add failed", 86 port->id, port->pid); 87 break; 88 } | 84 case NXT_OK: 85 break; 86 87 default: 88 nxt_thread_log_error(NXT_LOG_WARN, "port #%d for pid %PI add failed", 89 port->id, port->pid); 90 break; 91 } |
92 93 return res; |
|
89} 90 91 | 94} 95 96 |
92void | 97nxt_int_t |
93nxt_port_hash_remove(nxt_lvlhsh_t *port_hash, nxt_port_t *port) 94{ | 98nxt_port_hash_remove(nxt_lvlhsh_t *port_hash, nxt_port_t *port) 99{ |
100 nxt_int_t res; |
|
95 nxt_pid_port_id_t pid_port; 96 nxt_lvlhsh_query_t lhq; 97 98 pid_port.pid = port->pid; 99 pid_port.port_id = port->id; 100 101 nxt_port_hash_lhq(&lhq, &pid_port); 102 | 101 nxt_pid_port_id_t pid_port; 102 nxt_lvlhsh_query_t lhq; 103 104 pid_port.pid = port->pid; 105 pid_port.port_id = port->id; 106 107 nxt_port_hash_lhq(&lhq, &pid_port); 108 |
103 switch (nxt_lvlhsh_delete(port_hash, &lhq)) { | 109 res = nxt_lvlhsh_delete(port_hash, &lhq); |
104 | 110 |
111 switch (res) { 112 |
|
105 case NXT_OK: 106 break; 107 108 default: | 113 case NXT_OK: 114 break; 115 116 default: |
117 nxt_thread_log_error(NXT_LOG_WARN, "port #%d for pid %PI remove failed", 118 port->id, port->pid); |
|
109 break; 110 } | 119 break; 120 } |
121 122 return res; |
|
111} 112 113 114nxt_port_t * 115nxt_port_hash_find(nxt_lvlhsh_t *port_hash, nxt_pid_t pid, 116 nxt_port_id_t port_id) 117{ 118 nxt_pid_port_id_t pid_port; --- 16 unchanged lines hidden --- | 123} 124 125 126nxt_port_t * 127nxt_port_hash_find(nxt_lvlhsh_t *port_hash, nxt_pid_t pid, 128 nxt_port_id_t port_id) 129{ 130 nxt_pid_port_id_t pid_port; --- 16 unchanged lines hidden --- |