From dbc9edcaac6ec1d2059f4c5bcd27cca6c266f5bf Mon Sep 17 00:00:00 2001 From: markster Date: Wed, 13 Aug 2003 15:25:16 +0000 Subject: Totally revamp thread debugging to support locating and removing deadlocks git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1310 f38db490-d61c-443f-a65b-d21fe96a405b --- astmm.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'astmm.c') diff --git a/astmm.c b/astmm.c index 94e4555b5..ebc6fc1e0 100755 --- a/astmm.c +++ b/astmm.c @@ -55,7 +55,7 @@ static struct ast_region { #define HASH(a) \ (((unsigned long)(a)) % SOME_PRIME) -static pthread_mutex_t reglock = PTHREAD_MUTEX_INITIALIZER; +static ast_mutex_t reglock = PTHREAD_MUTEX_INITIALIZER; static inline void *__ast_alloc_region(size_t size, int which, const char *file, int lineno, const char *func) { @@ -63,7 +63,7 @@ static inline void *__ast_alloc_region(size_t size, int which, const char *file, void *ptr=NULL; int hash; reg = malloc(size + sizeof(struct ast_region)); - pthread_mutex_lock(®lock); + ast_mutex_lock(®lock); if (reg) { strncpy(reg->file, file, sizeof(reg->file) - 1); reg->file[sizeof(reg->file) - 1] = '\0'; @@ -77,7 +77,7 @@ static inline void *__ast_alloc_region(size_t size, int which, const char *file, reg->next = regions[hash]; regions[hash] = reg; } - pthread_mutex_unlock(®lock); + ast_mutex_unlock(®lock); if (!reg) { fprintf(stderr, "Out of memory :(\n"); if (mmlog) { @@ -94,7 +94,7 @@ static inline size_t __ast_sizeof_region(void *ptr) struct ast_region *reg; size_t len = 0; - pthread_mutex_lock(®lock); + ast_mutex_lock(®lock); reg = regions[hash]; while(reg) { if (reg->data == ptr) { @@ -103,7 +103,7 @@ static inline size_t __ast_sizeof_region(void *ptr) } reg = reg->next; } - pthread_mutex_unlock(®lock); + ast_mutex_unlock(®lock); return len; } @@ -111,7 +111,7 @@ static void __ast_free_region(void *ptr, const char *file, int lineno, const cha { int hash = HASH(ptr); struct ast_region *reg, *prev = NULL; - pthread_mutex_lock(®lock); + ast_mutex_lock(®lock); reg = regions[hash]; while(reg) { if (reg->data == ptr) { @@ -125,7 +125,7 @@ static void __ast_free_region(void *ptr, const char *file, int lineno, const cha prev = reg; reg = reg->next; } - pthread_mutex_unlock(®lock); + ast_mutex_unlock(®lock); if (reg) { free(reg); } else { @@ -226,7 +226,7 @@ static int handle_show_memory(int fd, int argc, char *argv[]) fn = argv[3]; /* try to lock applications list ... */ - pthread_mutex_lock(®lock); + ast_mutex_lock(®lock); for (x=0;xnext; } } - pthread_mutex_unlock(®lock); + ast_mutex_unlock(®lock); /* Dump the whole list */ while(list) { -- cgit v1.2.3