Browse Source

MT#55283 use typed GHashTable for local sockets

Change-Id: I88cb27e350c7b2c878764108a3a913f325f4fcb9
pull/1776/head
Richard Fuchs 2 years ago
parent
commit
2b41188286
2 changed files with 9 additions and 12 deletions
  1. +9
    -8
      daemon/media_socket.c
  2. +0
    -4
      lib/obj.h

+ 9
- 8
daemon/media_socket.c View File

@ -433,8 +433,9 @@ static GQueue __preferred_lists_for_family[__SF_LAST];
GQueue all_local_interfaces = G_QUEUE_INIT;
TYPED_GHASHTABLE(local_sockets_ht, endpoint_t, stream_fd, endpoint_t_hash, endpoint_t_eq, NULL, stream_fd_put)
rwlock_t local_media_socket_endpoints_lock;
static GHashTable *local_media_socket_endpoints;
static local_sockets_ht local_media_socket_endpoints;
@ -855,7 +856,7 @@ void interfaces_init(GQueue *interfaces) {
}
}
local_media_socket_endpoints = g_hash_table_new_full(endpoint_t_hash, endpoint_t_eq, NULL, obj_put_ptr);
local_media_socket_endpoints = local_sockets_ht_new();
rwlock_init(&local_media_socket_endpoints_lock);
}
@ -3262,7 +3263,7 @@ stream_fd *stream_fd_new(socket_t *fd, call_t *call, struct local_intf *lif) {
}
RWLOCK_W(&local_media_socket_endpoints_lock);
g_hash_table_replace(local_media_socket_endpoints, &sfd->socket.local, obj_get(sfd));
t_hash_table_replace(local_media_socket_endpoints, &sfd->socket.local, obj_get(sfd));
}
return sfd;
@ -3270,7 +3271,7 @@ stream_fd *stream_fd_new(socket_t *fd, call_t *call, struct local_intf *lif) {
stream_fd *stream_fd_lookup(const endpoint_t *ep) {
RWLOCK_R(&local_media_socket_endpoints_lock);
stream_fd *ret = g_hash_table_lookup(local_media_socket_endpoints, ep);
stream_fd *ret = t_hash_table_lookup(local_media_socket_endpoints, ep);
if (!ret)
return NULL;
obj_hold(ret);
@ -3285,9 +3286,9 @@ void stream_fd_release(stream_fd *sfd) {
{
RWLOCK_W(&local_media_socket_endpoints_lock);
stream_fd *ent = g_hash_table_lookup(local_media_socket_endpoints, &sfd->socket.local);
stream_fd *ent = t_hash_table_lookup(local_media_socket_endpoints, &sfd->socket.local);
if (ent == sfd)
g_hash_table_remove(local_media_socket_endpoints,
t_hash_table_remove(local_media_socket_endpoints,
&sfd->socket.local); // releases reference
}
@ -3381,8 +3382,8 @@ void interfaces_free(void) {
for (int i = 0; i < G_N_ELEMENTS(__preferred_lists_for_family); i++)
g_queue_clear(&__preferred_lists_for_family[i]);
g_hash_table_destroy(local_media_socket_endpoints);
local_media_socket_endpoints = NULL;
t_hash_table_destroy(local_media_socket_endpoints);
local_media_socket_endpoints = local_sockets_ht_null();
rwlock_destroy(&local_media_socket_endpoints_lock);
}


+ 0
- 4
lib/obj.h View File

@ -95,10 +95,6 @@ INLINE void __obj_put(struct obj *o);
#endif
INLINE void obj_put_ptr(void *p) {
obj_put_o(p);
}
#define obj_release(op) do { if (op) obj_put_o((struct obj *) op); op = NULL; } while (0)


Loading…
Cancel
Save