Totally revamp thread debugging to support locating and removing deadlocks

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1310 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2003-08-13 15:25:16 +00:00
parent 4a396046fe
commit 1bb58646de
76 changed files with 1789 additions and 1723 deletions

View File

@@ -75,7 +75,7 @@ static struct ast_atexit {
void (*func)(void);
struct ast_atexit *next;
} *atexits = NULL;
static pthread_mutex_t atexitslock = AST_MUTEX_INITIALIZER;
static ast_mutex_t atexitslock = AST_MUTEX_INITIALIZER;
time_t ast_startuptime;
time_t ast_lastreloadtime;
@@ -111,7 +111,7 @@ int ast_register_atexit(void (*func)(void))
struct ast_atexit *ae;
ast_unregister_atexit(func);
ae = malloc(sizeof(struct ast_atexit));
ast_pthread_mutex_lock(&atexitslock);
ast_mutex_lock(&atexitslock);
if (ae) {
memset(ae, 0, sizeof(struct ast_atexit));
ae->next = atexits;
@@ -119,14 +119,14 @@ int ast_register_atexit(void (*func)(void))
atexits = ae;
res = 0;
}
ast_pthread_mutex_unlock(&atexitslock);
ast_mutex_unlock(&atexitslock);
return res;
}
void ast_unregister_atexit(void (*func)(void))
{
struct ast_atexit *ae, *prev = NULL;
ast_pthread_mutex_lock(&atexitslock);
ast_mutex_lock(&atexitslock);
ae = atexits;
while(ae) {
if (ae->func == func) {
@@ -139,7 +139,7 @@ void ast_unregister_atexit(void (*func)(void))
prev = ae;
ae = ae->next;
}
ast_pthread_mutex_unlock(&atexitslock);
ast_mutex_unlock(&atexitslock);
}
static int fdprint(int fd, const char *s)
@@ -402,14 +402,14 @@ static int shuttingdown = 0;
static void ast_run_atexits(void)
{
struct ast_atexit *ae;
ast_pthread_mutex_lock(&atexitslock);
ast_mutex_lock(&atexitslock);
ae = atexits;
while(ae) {
if (ae->func)
ae->func();
ae = ae->next;
}
ast_pthread_mutex_unlock(&atexitslock);
ast_mutex_unlock(&atexitslock);
}
static void quit_handler(int num, int nice, int safeshutdown, int restart)