From 1d61214d9e2c0ba274d1ae7465a4d6baa63cac1c Mon Sep 17 00:00:00 2001 From: Nathan Kent Date: Tue, 23 Apr 2019 19:12:07 -0400 Subject: fixes #931 nng_ctx_send can block forever --- src/core/idhash.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/core/idhash.c b/src/core/idhash.c index a13a16c8..8f6e9406 100644 --- a/src/core/idhash.c +++ b/src/core/idhash.c @@ -98,11 +98,13 @@ static size_t nni_hash_find_index(nni_idhash *h, uint64_t id) { size_t index; + size_t start; if (h->ih_count == 0) { return ((size_t) -1); } index = NNI_IDHASH_INDEX(h, id); + start = index; for (;;) { // The value of ihe_key is only valid if ihe_val is not NULL. if ((h->ih_entries[index].ihe_key == id) && @@ -113,7 +115,13 @@ nni_hash_find_index(nni_idhash *h, uint64_t id) return ((size_t) -1); } index = NNI_IDHASH_NEXTPROBE(h, index); + + if (index == start) { + break; + } } + + return ((size_t) -1); } static int -- cgit v1.2.3-70-g09d2