diff options
| author | chenzizhan <[email protected]> | 2024-05-17 11:40:16 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2024-05-17 11:40:16 +0800 |
| commit | 5c39e8e0f8627ae0d7c72c0967bec000ee0010ea (patch) | |
| tree | 3bbdcbf2f3503c2e111d1e5126a180026377a553 /src | |
| parent | 25681060f7a771e3ec753eb9f7fb23df959001f1 (diff) | |
troubleshoot about the confusion of dying and dummyv4.5.9
Diffstat (limited to 'src')
| -rw-r--r-- | src/tags/sorted_set.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/tags/sorted_set.c b/src/tags/sorted_set.c index a6e3456..ae315d5 100644 --- a/src/tags/sorted_set.c +++ b/src/tags/sorted_set.c @@ -89,7 +89,12 @@ bool sorted_set_entry_dying(const heap_entry *entry) // cppcheck-suppress [constParameterCallback, unmatchedSuppression]
static bool cmp_int(void *aa, void *bb)
{
- if (sorted_set_entry_get_count(aa) < sorted_set_entry_get_count(bb)) {
+ heap_entry *a = (heap_entry *)aa;
+ heap_entry *b = (heap_entry *)bb;
+ unsigned long long count_a = *(unsigned long long *)a->key;
+ unsigned long long count_b = *(unsigned long long *)b->key;
+
+ if (count_a < count_b) {
return true;
}
return false;
@@ -349,7 +354,13 @@ int sorted_set_incrby(struct sorted_set *ss, const struct tag_hash_key *tag, uns if (entry == NULL) {
return -1;
}
- unsigned long long cnt_old = sorted_set_entry_get_count(entry);
+ unsigned long long cnt_old;
+ if (sorted_set_entry_dying(entry) == false) {
+ cnt_old = sorted_set_entry_get_count(entry);
+ cnt_old += 1; // sorted set will let the count start from 1, 0 for dying entry.
+ } else {
+ cnt_old = 0;
+ }
sorted_set_entry_set_key(ss, entry, safe_add(count, cnt_old));
return 0;
}
|
