From de80ed87b8339f23624642786698057a62bdf779 Mon Sep 17 00:00:00 2001 From: fujuntang <fujuntang@smartai.com> Date: 星期二, 23 十一月 2021 11:25:48 +0800 Subject: [PATCH] Fix the communication failure issue when the registered applications exceeds the fixed amount. --- src/shm/hashtable.cpp | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/shm/hashtable.cpp b/src/shm/hashtable.cpp index 2cc9e38..ab07ad1 100755 --- a/src/shm/hashtable.cpp +++ b/src/shm/hashtable.cpp @@ -53,7 +53,7 @@ TAILQ_FOREACH(item, my_tailq_head, joint) { - if ((check_mm_valid(item) == true) && (key == item->key)) + if ((check_mm_valid(item) == true) && ((key == item->key) || (code == item->key))) return item->value; break; @@ -316,8 +316,15 @@ static size_t hashcode(int key) { + int val; - return key % MAPSIZE; + if (key < MAPSIZE) { + val = key; + } else { + val = key % MAPSIZE % (MAPSIZE - START_KEY) + START_KEY; + } + + return val; } /** -- Gitblit v1.8.0