diff --git a/daemon/call.c b/daemon/call.c index 9f94bd635..962c593d9 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -4182,7 +4182,7 @@ void call_destroy(call_t *c) { } } - k = g_hash_table_get_values(ml->ssrc_hash->ht); + k = g_hash_table_get_values(ml->ssrc_hash->nht); while (k) { struct ssrc_entry_call *se = k->data; diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 06a7e1efd..6472a23a1 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -3031,7 +3031,7 @@ static void ng_stats_ssrc_mos_entry_dict_avg(const ng_parser_t *parser, parser_a } static void ng_stats_ssrc(const ng_parser_t *parser, parser_arg dict, struct ssrc_hash *ht) { - GList *ll = g_hash_table_get_values(ht->ht); + GList *ll = g_hash_table_get_values(ht->nht); for (GList *l = ll; l; l = l->next) { struct ssrc_entry_call *se = l->data; diff --git a/daemon/redis.c b/daemon/redis.c index feb673d49..a4411c544 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -2637,7 +2637,7 @@ static str redis_encode_json(ng_parser_ctx_t *ctx, call_t *c, void **to_free) { // SSRC table dump rwlock_lock_r(&ml->ssrc_hash->lock); - k = g_hash_table_get_values(ml->ssrc_hash->ht); + k = g_hash_table_get_values(ml->ssrc_hash->nht); snprintf(tmp, sizeof(tmp), "ssrc_table-%u", ml->unique_id); parser_arg list = parser->dict_add_list_dup(root, tmp); for (GList *m = k; m; m = m->next) { diff --git a/daemon/ssrc.c b/daemon/ssrc.c index 603b7e114..88ea30488 100644 --- a/daemon/ssrc.c +++ b/daemon/ssrc.c @@ -52,7 +52,7 @@ static struct ssrc_entry *create_ssrc_entry_call(void *uptr) { } static void add_ssrc_entry(uint32_t ssrc, struct ssrc_entry *ent, struct ssrc_hash *ht) { init_ssrc_entry(ent, ssrc); - g_hash_table_replace(ht->ht, &ent->ssrc, ent); + g_hash_table_replace(ht->nht, GUINT_TO_POINTER(ent->ssrc), ent); obj_hold(ent); // HT entry g_queue_push_tail(&ht->q, ent); obj_hold(ent); // queue entry @@ -190,7 +190,7 @@ static void *find_ssrc(uint32_t ssrc, struct ssrc_hash *ht) { rwlock_lock_r(&ht->lock); struct ssrc_entry *ret = atomic_get_na(&ht->cache); if (!ret || ret->ssrc != ssrc) { - ret = g_hash_table_lookup(ht->ht, &ssrc); + ret = g_hash_table_lookup(ht->nht, GUINT_TO_POINTER(ssrc)); if (ret) { obj_hold(ret); // cache shares the reference from ht @@ -253,11 +253,11 @@ restart: "deleting SSRC %s%x%s", FMT_M(ssrc), FMT_M(old_ent->ssrc)); atomic_set(&ht->cache, NULL); - g_hash_table_remove(ht->ht, &old_ent->ssrc); // does obj_put + g_hash_table_remove(ht->nht, GUINT_TO_POINTER(old_ent->ssrc)); // does obj_put obj_put(old_ent); // for the queue entry } - if (g_hash_table_lookup(ht->ht, &ssrc)) { + if (g_hash_table_lookup(ht->nht, GUINT_TO_POINTER(ssrc))) { // preempted rwlock_unlock_w(&ht->lock); // return created entry if slot is still empty @@ -277,7 +277,7 @@ restart: void free_ssrc_hash(struct ssrc_hash **ht) { if (!*ht) return; - g_hash_table_destroy((*ht)->ht); + g_hash_table_destroy((*ht)->nht); g_queue_clear_full(&(*ht)->q, ssrc_entry_put); if ((*ht)->precreat) obj_put((struct ssrc_entry *) (*ht)->precreat); @@ -302,7 +302,7 @@ void ssrc_hash_foreach(struct ssrc_hash *sh, void (*f)(void *, void *), void *pt struct ssrc_hash *create_ssrc_hash_full_fast(ssrc_create_func_t cfunc, void *uptr) { struct ssrc_hash *ret; ret = g_new0(__typeof(*ret), 1); - ret->ht = g_hash_table_new_full(uint32_hash, uint32_eq, NULL, ssrc_entry_put); + ret->nht = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, ssrc_entry_put); rwlock_init(&ret->lock); ret->create_func = cfunc; ret->uptr = uptr; diff --git a/include/ssrc.h b/include/ssrc.h index f3065da2b..2afc1e710 100644 --- a/include/ssrc.h +++ b/include/ssrc.h @@ -19,7 +19,7 @@ enum ssrc_dir; typedef struct ssrc_entry *(*ssrc_create_func_t)(void *uptr); struct ssrc_hash { - GHashTable *ht; + GHashTable *nht; GQueue q; rwlock_t lock; ssrc_create_func_t create_func; diff --git a/lib/auxlib.c b/lib/auxlib.c index 236721b2e..7386abc7d 100644 --- a/lib/auxlib.c +++ b/lib/auxlib.c @@ -537,15 +537,6 @@ int in6_addr_eq(const void *a, const void *b) { return !memcmp(A, B, sizeof(*A)); } -unsigned int uint32_hash(const void *p) { - const uint32_t *a = p; - return *a; -} -int uint32_eq(const void *a, const void *b) { - const uint32_t *A = a, *B = b; - return (*A == *B) ? TRUE : FALSE; -} - int timeval_cmp_zero(const void *a, const void *b) { const struct timeval *A = a, *B = b; diff --git a/lib/auxlib.h b/lib/auxlib.h index 10206d6f4..131b330cb 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -114,8 +114,6 @@ int thread_create(void *(*func)(void *), void *arg, bool joinable, pthread_t *ha unsigned int in6_addr_hash(const void *p); int in6_addr_eq(const void *a, const void *b); -unsigned int uint32_hash(const void *p); -int uint32_eq(const void *a, const void *b); int num_cpu_cores(int);