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

@@ -46,7 +46,7 @@ struct ast_filestream {
};
static pthread_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
static ast_mutex_t pcm_lock = AST_MUTEX_INITIALIZER;
static int glistcnt = 0;
static char *name = "pcm";
@@ -61,7 +61,7 @@ static struct ast_filestream *pcm_open(int fd)
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
if (pthread_mutex_lock(&pcm_lock)) {
if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
free(tmp);
return NULL;
@@ -74,7 +74,7 @@ static struct ast_filestream *pcm_open(int fd)
tmp->fr.src = name;
tmp->fr.mallocd = 0;
glistcnt++;
pthread_mutex_unlock(&pcm_lock);
ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
}
return tmp;
@@ -88,14 +88,14 @@ static struct ast_filestream *pcm_rewrite(int fd, char *comment)
struct ast_filestream *tmp;
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
if (pthread_mutex_lock(&pcm_lock)) {
if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
free(tmp);
return NULL;
}
tmp->fd = fd;
glistcnt++;
pthread_mutex_unlock(&pcm_lock);
ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
} else
ast_log(LOG_WARNING, "Out of memory\n");
@@ -104,11 +104,11 @@ static struct ast_filestream *pcm_rewrite(int fd, char *comment)
static void pcm_close(struct ast_filestream *s)
{
if (pthread_mutex_lock(&pcm_lock)) {
if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
return;
}
pthread_mutex_unlock(&pcm_lock);
ast_mutex_unlock(&pcm_lock);
ast_update_use_count();
close(s->fd);
free(s);
@@ -215,12 +215,12 @@ int unload_module()
int usecount()
{
int res;
if (pthread_mutex_lock(&pcm_lock)) {
if (ast_mutex_lock(&pcm_lock)) {
ast_log(LOG_WARNING, "Unable to lock pcm list\n");
return -1;
}
res = glistcnt;
pthread_mutex_unlock(&pcm_lock);
ast_mutex_unlock(&pcm_lock);
return res;
}