AST_LIST_ENTRY(tls_object) entry;
};
-static AST_RWLIST_HEAD_STATIC(tls_objects, tls_object);
+static AST_LIST_HEAD_NOLOCK_STATIC(tls_objects, tls_object);
+AST_MUTEX_DEFINE_STATIC_NOTRACKING(threadstoragelock);
+
void __ast_threadstorage_object_add(void *key, size_t len, const char *file, const char *function, unsigned int line)
{
to->line = line;
to->thread = pthread_self();
- AST_RWLIST_WRLOCK(&tls_objects);
+ ast_mutex_lock(&threadstoragelock);
AST_LIST_INSERT_TAIL(&tls_objects, to, entry);
- AST_RWLIST_UNLOCK(&tls_objects);
+ ast_mutex_unlock(&threadstoragelock);
}
void __ast_threadstorage_object_remove(void *key)
{
struct tls_object *to;
- AST_RWLIST_WRLOCK(&tls_objects);
+ ast_mutex_lock(&threadstoragelock);
AST_LIST_TRAVERSE_SAFE_BEGIN(&tls_objects, to, entry) {
if (to->key == key) {
AST_LIST_REMOVE_CURRENT(entry);
}
}
AST_LIST_TRAVERSE_SAFE_END;
- AST_RWLIST_UNLOCK(&tls_objects);
+ ast_mutex_unlock(&threadstoragelock);
if (to)
ast_free(to);
}
{
struct tls_object *to;
- AST_RWLIST_WRLOCK(&tls_objects);
+ ast_mutex_lock(&threadstoragelock);
AST_LIST_TRAVERSE_SAFE_BEGIN(&tls_objects, to, entry) {
if (to->key == key_old) {
to->key = key_new;
}
}
AST_LIST_TRAVERSE_SAFE_END;
- AST_RWLIST_UNLOCK(&tls_objects);
+ ast_mutex_unlock(&threadstoragelock);
}
static char *handle_cli_threadstorage_show_allocations(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
if (a->argc > 3)
fn = a->argv[3];
- AST_RWLIST_RDLOCK(&tls_objects);
+ ast_mutex_lock(&threadstoragelock);
AST_LIST_TRAVERSE(&tls_objects, to, entry) {
if (fn && strcasecmp(to->file, fn))
count++;
}
- AST_RWLIST_UNLOCK(&tls_objects);
+ ast_mutex_unlock(&threadstoragelock);
ast_cli(a->fd, "%10d bytes allocated in %d allocation%s\n", (int) len, count, count > 1 ? "s" : "");
if (a->argc > 3)
fn = a->argv[3];
- AST_RWLIST_RDLOCK(&tls_objects);
+ ast_mutex_lock(&threadstoragelock);
AST_LIST_TRAVERSE(&tls_objects, to, entry) {
if (fn && strcasecmp(to->file, fn))
file->count++;
}
- AST_RWLIST_UNLOCK(&tls_objects);
+ ast_mutex_unlock(&threadstoragelock);
AST_LIST_TRAVERSE(&file_summary, file, entry) {
len += file->len;