From: Michael Wallner Date: Tue, 21 Jan 2020 16:38:13 +0000 (+0100) Subject: libmemcached: fix #41 (ensure stable sort on host key collision) X-Git-Tag: pre_cmake~20 X-Git-Url: https://git.m6w6.name/?p=awesomized%2Flibmemcached;a=commitdiff_plain;h=fba95501bb492d279f66ab91ec317139213d04d0 libmemcached: fix #41 (ensure stable sort on host key collision) --- diff --git a/libmemcached/hosts.cc b/libmemcached/hosts.cc index 97f7c35b..98cb3f7d 100644 --- a/libmemcached/hosts.cc +++ b/libmemcached/hosts.cc @@ -120,7 +120,18 @@ static int continuum_item_cmp(const void *t1, const void *t2) WATCHPOINT_ASSERT(ct1->value != 153); if (ct1->value == ct2->value) { - return 0; + if (ct1->index == ct2->index) + { + return 0; + } + else if (ct1->index > ct2->index) + { + return 1; + } + else + { + return -1; + } } else if (ct1->value > ct2->value) {