MT#61822 add RWLOCK_STATIC_INIT

Change-Id: I6718df967b70554a32c3caddcb4e29af4fb6d7f0
pull/1897/head
Richard Fuchs 4 months ago
parent 0bb7302d5c
commit ad8ce3541d

@ -55,7 +55,7 @@ struct xmlrpc_helper {
GQueue strings;
};
rwlock_t rtpe_callhash_lock;
rwlock_t rtpe_callhash_lock = RWLOCK_STATIC_INIT;
rtpe_calls_ht rtpe_callhash;
struct call_iterator_list rtpe_call_iterators[NUM_CALL_ITERATORS];
__thread call_t *call_memory_arena;
@ -587,7 +587,6 @@ int call_init(void) {
rtpe_callhash = rtpe_calls_ht_new();
if (!t_hash_table_is_set(rtpe_callhash))
return -1;
rwlock_init(&rtpe_callhash_lock);
for (int i = 0; i < NUM_CALL_ITERATORS; i++)
mutex_init(&rtpe_call_iterators[i].lock);

@ -99,7 +99,7 @@ const int num_hash_funcs = G_N_ELEMENTS(hash_funcs);
static struct dtls_cert *__dtls_cert;
static rwlock_t __dtls_cert_lock;
static rwlock_t __dtls_cert_lock = RWLOCK_STATIC_INIT;
@ -379,7 +379,6 @@ int dtls_init(void) {
int i;
char *p;
rwlock_init(&__dtls_cert_lock);
if (cert_init())
return -1;

@ -435,7 +435,7 @@ 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_hash, endpoint_eq, NULL, stream_fd_put)
static rwlock_t local_media_socket_endpoints_lock;
static rwlock_t local_media_socket_endpoints_lock = RWLOCK_STATIC_INIT;
static local_sockets_ht local_media_socket_endpoints;
__thread struct bufferpool *media_bufferpool;
@ -881,7 +881,6 @@ void interfaces_init(intf_config_q *interfaces) {
}
local_media_socket_endpoints = local_sockets_ht_new();
rwlock_init(&local_media_socket_endpoints_lock);
}
void interfaces_exclude_port(unsigned int port) {
@ -3268,7 +3267,6 @@ void interfaces_free(void) {
t_hash_table_destroy(local_media_socket_endpoints);
local_media_socket_endpoints = local_sockets_ht_null();
rwlock_destroy(&local_media_socket_endpoints_lock);
}

@ -135,6 +135,7 @@ typedef pthread_cond_t cond_t;
#define rwlock_lock_w(l) __debug_rwlock_lock_w(l, __FILE__, __LINE__)
#define rwlock_trylock_w(l) __debug_rwlock_trylock_w(l, __FILE__, __LINE__)
#define rwlock_unlock_w(l) __debug_rwlock_unlock_w(l, __FILE__, __LINE__)
#define RWLOCK_STATIC_INIT PTHREAD_RWLOCK_INITIALIZER
#define cond_init(c) __debug_cond_init(c, __FILE__, __LINE__)
#define cond_wait(c,m) __debug_cond_wait(c,m, __FILE__, __LINE__)

@ -29,7 +29,7 @@ struct bpool_shard {
};
// sorted list of all shards for quick bsearch
static rwlock_t bpool_shards_lock;
static rwlock_t bpool_shards_lock = RWLOCK_STATIC_INIT;
static GPtrArray *bpool_shards;
static struct bufferpool *bufferpool_new_common(void *(*alloc)(size_t), size_t shard_size) {
@ -307,12 +307,10 @@ void bufferpool_destroy(struct bufferpool *bp) {
}
void bufferpool_init(void) {
rwlock_init(&bpool_shards_lock);
bpool_shards = g_ptr_array_new();
}
void bufferpool_cleanup(void) {
rwlock_destroy(&bpool_shards_lock);
assert(bpool_shards->len == 0);
g_ptr_array_free(bpool_shards, true);
}

Loading…
Cancel
Save