diff options
author | Igor Sysoev <igor@sysoev.ru> | 2018-03-29 16:35:36 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2018-03-29 16:35:36 +0300 |
commit | 7205bf4b86cfa662a7267afd7c316118084fc600 (patch) | |
tree | bddd69d9801ef74f6d61cdfda57d1af625ab714f /src | |
parent | aad7752527faf674bcb01408e997769ba48756d7 (diff) | |
download | unit-7205bf4b86cfa662a7267afd7c316118084fc600.tar.gz unit-7205bf4b86cfa662a7267afd7c316118084fc600.tar.bz2 |
Using nxt_lvlhsh_peek() and nxt_lvlhsh_retrieve().
Diffstat (limited to '')
-rw-r--r-- | src/nxt_fd_event.c | 26 | ||||
-rw-r--r-- | src/nxt_poll_engine.c | 14 | ||||
-rw-r--r-- | src/nxt_port_rpc.c | 7 |
3 files changed, 6 insertions, 41 deletions
diff --git a/src/nxt_fd_event.c b/src/nxt_fd_event.c index a5e0a3ef..dffe1026 100644 --- a/src/nxt_fd_event.c +++ b/src/nxt_fd_event.c @@ -96,30 +96,12 @@ nxt_fd_event_hash_delete(nxt_task_t *task, nxt_lvlhsh_t *lvlhsh, nxt_fd_t fd, void nxt_fd_event_hash_destroy(nxt_lvlhsh_t *lvlhsh) { - nxt_int_t ret; - nxt_fd_event_t *ev; - nxt_lvlhsh_each_t lhe; - nxt_lvlhsh_query_t lhq; - - nxt_memzero(&lhe, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &nxt_event_set_fd_hash_proto; - lhq.proto = &nxt_event_set_fd_hash_proto; - - for ( ;; ) { - ev = nxt_lvlhsh_each(lvlhsh, &lhe); + nxt_fd_event_t *ev; - if (ev == NULL) { - return; - } - - lhq.key_hash = nxt_murmur_hash2(&ev->fd, sizeof(nxt_fd_t)); - - ret = nxt_lvlhsh_delete(lvlhsh, &lhq); + do { + ev = nxt_lvlhsh_retrieve(lvlhsh, &nxt_event_set_fd_hash_proto, NULL); - if (nxt_slow_path(ret != NXT_OK)) { - nxt_fd_event_hash_error(ev->task, ev->fd); - } - } + } while (ev != NULL); } diff --git a/src/nxt_poll_engine.c b/src/nxt_poll_engine.c index 9b70f8d6..acb44a22 100644 --- a/src/nxt_poll_engine.c +++ b/src/nxt_poll_engine.c @@ -680,27 +680,15 @@ nxt_poll_fd_hash_test(nxt_lvlhsh_query_t *lhq, void *data) static void nxt_poll_fd_hash_destroy(nxt_event_engine_t *engine, nxt_lvlhsh_t *lh) { - nxt_lvlhsh_each_t lhe; - nxt_lvlhsh_query_t lhq; nxt_poll_hash_entry_t *phe; - nxt_memzero(&lhe, sizeof(nxt_lvlhsh_each_t)); - lhe.proto = &nxt_poll_fd_hash_proto; - lhq.proto = &nxt_poll_fd_hash_proto; - for ( ;; ) { - phe = nxt_lvlhsh_each(lh, &lhe); + phe = nxt_lvlhsh_retrieve(lh, &nxt_poll_fd_hash_proto, NULL); if (phe == NULL) { return; } - lhq.key_hash = nxt_murmur_hash2(&phe->fd, sizeof(nxt_fd_t)); - - if (nxt_lvlhsh_delete(lh, &lhq) != NXT_OK) { - nxt_alert(&engine->task, "event fd %d not found in hash", phe->fd); - } - nxt_free(phe); } } diff --git a/src/nxt_port_rpc.c b/src/nxt_port_rpc.c index d5ec289c..3e29230a 100644 --- a/src/nxt_port_rpc.c +++ b/src/nxt_port_rpc.c @@ -467,16 +467,11 @@ static nxt_buf_t nxt_port_close_dummy_buf; void nxt_port_rpc_close(nxt_task_t *task, nxt_port_t *port) { - nxt_lvlhsh_each_t lhe; nxt_port_rpc_reg_t *reg; nxt_port_recv_msg_t msg; for ( ;; ) { - nxt_memzero(&lhe, sizeof(nxt_lvlhsh_each_t)); - - lhe.proto = &lvlhsh_rpc_reg_proto; - - reg = nxt_lvlhsh_each(&port->rpc_streams, &lhe); + reg = nxt_lvlhsh_peek(&port->rpc_streams, &lvlhsh_rpc_reg_proto); if (reg == NULL) { return; } |