aboutsummaryrefslogtreecommitdiffstats
path: root/main/threadstorage.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-05 00:12:10 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-05 00:12:10 +0000
commit70037743883a294d3163897d6f2d0f62281dc8eb (patch)
tree6ca5986c6511aceddb8afbb1bb95225a27848eea /main/threadstorage.c
parentdb025d69ebd1d8eba579f50cd1fe4cd337f3d86a (diff)
use a rwlock-list for the list of TLS objects
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@49608 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/threadstorage.c')
-rw-r--r--main/threadstorage.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/main/threadstorage.c b/main/threadstorage.c
index b4d38c045..b481343df 100644
--- a/main/threadstorage.c
+++ b/main/threadstorage.c
@@ -50,7 +50,7 @@ struct tls_object {
AST_LIST_ENTRY(tls_object) entry;
};
-static AST_LIST_HEAD_STATIC(tls_objects, tls_object);
+static AST_RWLIST_HEAD_STATIC(tls_objects, tls_object);
void __ast_threadstorage_object_add(void *key, size_t len, const char *file, const char *function, unsigned int line)
{
@@ -66,16 +66,16 @@ void __ast_threadstorage_object_add(void *key, size_t len, const char *file, con
to->line = line;
to->thread = pthread_self();
- AST_LIST_LOCK(&tls_objects);
+ AST_RWLIST_WRLOCK(&tls_objects);
AST_LIST_INSERT_TAIL(&tls_objects, to, entry);
- AST_LIST_UNLOCK(&tls_objects);
+ AST_RWLIST_UNLOCK(&tls_objects);
}
void __ast_threadstorage_object_remove(void *key)
{
struct tls_object *to;
- AST_LIST_LOCK(&tls_objects);
+ AST_RWLIST_WRLOCK(&tls_objects);
AST_LIST_TRAVERSE_SAFE_BEGIN(&tls_objects, to, entry) {
if (to->key == key) {
AST_LIST_REMOVE_CURRENT(&tls_objects, entry);
@@ -83,7 +83,7 @@ void __ast_threadstorage_object_remove(void *key)
}
}
AST_LIST_TRAVERSE_SAFE_END;
- AST_LIST_UNLOCK(&tls_objects);
+ AST_RWLIST_UNLOCK(&tls_objects);
if (to)
free(to);
}
@@ -92,7 +92,7 @@ void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len
{
struct tls_object *to;
- AST_LIST_LOCK(&tls_objects);
+ AST_RWLIST_WRLOCK(&tls_objects);
AST_LIST_TRAVERSE_SAFE_BEGIN(&tls_objects, to, entry) {
if (to->key == key_old) {
to->key = key_new;
@@ -101,7 +101,7 @@ void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len
}
}
AST_LIST_TRAVERSE_SAFE_END;
- AST_LIST_UNLOCK(&tls_objects);
+ AST_RWLIST_UNLOCK(&tls_objects);
}
static int handle_show_allocations(int fd, int argc, char *argv[])
@@ -114,7 +114,7 @@ static int handle_show_allocations(int fd, int argc, char *argv[])
if (argc > 3)
fn = argv[3];
- AST_LIST_LOCK(&tls_objects);
+ AST_RWLIST_RDLOCK(&tls_objects);
AST_LIST_TRAVERSE(&tls_objects, to, entry) {
if (fn && strcasecmp(to->file, fn))
@@ -126,7 +126,7 @@ static int handle_show_allocations(int fd, int argc, char *argv[])
count++;
}
- AST_LIST_UNLOCK(&tls_objects);
+ AST_RWLIST_UNLOCK(&tls_objects);
ast_cli(fd, "%10d bytes allocated in %d allocation%s\n", (int) len, count, count > 1 ? "s" : "");
@@ -150,7 +150,7 @@ static int handle_show_summary(int fd, int argc, char *argv[])
if (argc > 3)
fn = argv[3];
- AST_LIST_LOCK(&tls_objects);
+ AST_RWLIST_RDLOCK(&tls_objects);
AST_LIST_TRAVERSE(&tls_objects, to, entry) {
if (fn && strcasecmp(to->file, fn))
@@ -172,7 +172,7 @@ static int handle_show_summary(int fd, int argc, char *argv[])
file->count++;
}
- AST_LIST_UNLOCK(&tls_objects);
+ AST_RWLIST_UNLOCK(&tls_objects);
AST_LIST_TRAVERSE(&file_summary, file, entry) {
len += file->len;