From fba95501bb492d279f66ab91ec317139213d04d0 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 21 Jan 2020 17:38:13 +0100 Subject: [PATCH] libmemcached: fix #41 (ensure stable sort on host key collision) --- libmemcached/hosts.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) { -- 2.30.2