From: Jérémie Galarneau Date: Fri, 17 Aug 2018 17:25:53 +0000 (-0400) Subject: Fix: use condition's type to compute its hash X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=9a2746aaa1cddad6737cbba2bcae739cb3b84617 Fix: use condition's type to compute its hash Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index 98757737d..e55c0668a 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -294,12 +294,15 @@ static unsigned long lttng_condition_buffer_usage_hash( const struct lttng_condition *_condition) { - unsigned long hash = 0; + unsigned long hash; + unsigned long condition_type; struct lttng_condition_buffer_usage *condition; condition = container_of(_condition, struct lttng_condition_buffer_usage, parent); + condition_type = (unsigned long) condition->parent.type; + hash = hash_key_ulong((void *) condition_type, lttng_ht_seed); if (condition->session_name) { hash ^= hash_key_str(condition->session_name, lttng_ht_seed); } @@ -329,13 +332,16 @@ static unsigned long lttng_condition_session_consumed_size_hash( const struct lttng_condition *_condition) { - unsigned long hash = 0; + unsigned long hash; + unsigned long condition_type = + (unsigned long) LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE; struct lttng_condition_session_consumed_size *condition; uint64_t val; condition = container_of(_condition, struct lttng_condition_session_consumed_size, parent); + hash = hash_key_ulong((void *) condition_type, lttng_ht_seed); if (condition->session_name) { hash ^= hash_key_str(condition->session_name, lttng_ht_seed); } @@ -344,6 +350,7 @@ unsigned long lttng_condition_session_consumed_size_hash( return hash; } + /* * The lttng_condition hashing code is kept in this file (rather than * condition.c) since it makes use of GPLv2 code (hashtable utils), which we diff --git a/src/common/hashtable/utils.c b/src/common/hashtable/utils.c index c9d75e289..9a84265a0 100644 --- a/src/common/hashtable/utils.c +++ b/src/common/hashtable/utils.c @@ -469,6 +469,7 @@ unsigned long hash_key_u64(const void *_key, unsigned long seed) #if (CAA_BITS_PER_LONG == 64) /* * Hash function for number value. + * Pass the value itself as the key, not its address. */ LTTNG_HIDDEN unsigned long hash_key_ulong(const void *_key, unsigned long seed) @@ -479,6 +480,7 @@ unsigned long hash_key_ulong(const void *_key, unsigned long seed) #else /* * Hash function for number value. + * Pass the value itself as the key, not its address. */ LTTNG_HIDDEN unsigned long hash_key_ulong(const void *_key, unsigned long seed)