mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 08:11:21 +00:00
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:
14
asterisk.c
14
asterisk.c
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user