Index: lock.h =================================================================== --- lock.h (revision 84819) +++ lock.h (working copy) @@ -165,6 +165,7 @@ const char *mutex_name, ast_mutex_t *t, pthread_mutexattr_t *attr) { + int i; #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS int canlog = strcmp(filename, "logger.c"); @@ -180,10 +181,17 @@ } #endif - t->file[0] = filename; - t->lineno[0] = lineno; - t->func[0] = func; - t->thread[0] = 0; + //t->file[0] = filename; + //t->lineno[0] = lineno; + //t->func[0] = func; + //t->thread[0] = 0; + for (i=0; ifile[i] = NULL; + t->lineno[i] = 0; + t->func[i] = NULL; + t->thread[i] = 0; + }; + t->reentrancy = 0; t->track = track; @@ -229,8 +237,8 @@ case EBUSY: __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n", filename, lineno, func, mutex_name); - __ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n", - t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name); + //__ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n", + // t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name); break; } @@ -282,9 +290,9 @@ if ((current - seconds) && (!((current - seconds) % 5))) { __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n", filename, lineno, func, (int)(current - seconds), mutex_name); - __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", - t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], - t->func[t->reentrancy-1], mutex_name); + //__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", + // t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], + // t->func[t->reentrancy-1], mutex_name); } usleep(200); } @@ -303,16 +311,16 @@ if (!res) { if (t->track) ast_mark_lock_acquired(); - if (t->reentrancy < AST_MAX_REENTRANCY) { - t->file[t->reentrancy] = filename; - t->lineno[t->reentrancy] = lineno; - t->func[t->reentrancy] = func; - t->thread[t->reentrancy] = pthread_self(); - t->reentrancy++; - } else { - __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", - filename, lineno, func, mutex_name); - } + //if (t->reentrancy < AST_MAX_REENTRANCY) { + // t->file[t->reentrancy] = filename; + // t->lineno[t->reentrancy] = lineno; + // t->func[t->reentrancy] = func; + // t->thread[t->reentrancy] = pthread_self(); + // t->reentrancy++; + //} else { + // __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", + // filename, lineno, func, mutex_name); + //} } else { if (t->track) ast_remove_lock_info(&t->mutex); @@ -344,16 +352,16 @@ if (!(res = pthread_mutex_trylock(&t->mutex))) { if (t->track) ast_mark_lock_acquired(); - if (t->reentrancy < AST_MAX_REENTRANCY) { - t->file[t->reentrancy] = filename; - t->lineno[t->reentrancy] = lineno; - t->func[t->reentrancy] = func; - t->thread[t->reentrancy] = pthread_self(); - t->reentrancy++; - } else { - __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", - filename, lineno, func, mutex_name); - } + //if (t->reentrancy < AST_MAX_REENTRANCY) { + // t->file[t->reentrancy] = filename; + // t->lineno[t->reentrancy] = lineno; + // t->func[t->reentrancy] = func; + // t->thread[t->reentrancy] = pthread_self(); + // t->reentrancy++; + //} else { + // __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", + // filename, lineno, func, mutex_name); + //} } else if (t->track) { ast_remove_lock_info(&t->mutex); } @@ -374,26 +382,26 @@ } #endif - if (t->reentrancy && (t->thread[t->reentrancy-1] != pthread_self())) { - __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", - filename, lineno, func, mutex_name); - __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", - t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name); - DO_THREAD_CRASH; - } + //if (t->reentrancy && (t->thread[t->reentrancy-1] != pthread_self())) { + // __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", + // filename, lineno, func, mutex_name); + // __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", + // t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name); + // DO_THREAD_CRASH; + //} - if (--t->reentrancy < 0) { - __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", - filename, lineno, func, mutex_name); - t->reentrancy = 0; - } + //if (--t->reentrancy < 0) { + // __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", + // filename, lineno, func, mutex_name); + // t->reentrancy = 0; + //} - if (t->reentrancy < AST_MAX_REENTRANCY) { - t->file[t->reentrancy] = NULL; - t->lineno[t->reentrancy] = 0; - t->func[t->reentrancy] = NULL; - t->thread[t->reentrancy] = 0; - } + //if (t->reentrancy < AST_MAX_REENTRANCY) { + // t->file[t->reentrancy] = NULL; + // t->lineno[t->reentrancy] = 0; + // t->func[t->reentrancy] = NULL; + // t->thread[t->reentrancy] = 0; + //} if (t->track) ast_remove_lock_info(&t->mutex); @@ -445,26 +453,26 @@ } #endif - if (t->reentrancy && (t->thread[t->reentrancy-1] != pthread_self())) { - __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", - filename, lineno, func, mutex_name); - __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", - t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name); - DO_THREAD_CRASH; - } + //if (t->reentrancy && (t->thread[t->reentrancy-1] != pthread_self())) { + // __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", + // filename, lineno, func, mutex_name); + // __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", + // t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name); + // DO_THREAD_CRASH; + //} - if (--t->reentrancy < 0) { - __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", - filename, lineno, func, mutex_name); - t->reentrancy = 0; - } + //if (--t->reentrancy < 0) { + // __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", + // filename, lineno, func, mutex_name); + // t->reentrancy = 0; + //} - if (t->reentrancy < AST_MAX_REENTRANCY) { - t->file[t->reentrancy] = NULL; - t->lineno[t->reentrancy] = 0; - t->func[t->reentrancy] = NULL; - t->thread[t->reentrancy] = 0; - } + //if (t->reentrancy < AST_MAX_REENTRANCY) { + // t->file[t->reentrancy] = NULL; + // t->lineno[t->reentrancy] = 0; + // t->func[t->reentrancy] = NULL; + // t->thread[t->reentrancy] = 0; + //} if (t->track) ast_remove_lock_info(&t->mutex); @@ -477,16 +485,16 @@ if (t->track) ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); - if (t->reentrancy < AST_MAX_REENTRANCY) { - t->file[t->reentrancy] = filename; - t->lineno[t->reentrancy] = lineno; - t->func[t->reentrancy] = func; - t->thread[t->reentrancy] = pthread_self(); - t->reentrancy++; - } else { - __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", - filename, lineno, func, mutex_name); - } + //if (t->reentrancy < AST_MAX_REENTRANCY) { + // t->file[t->reentrancy] = filename; + // t->lineno[t->reentrancy] = lineno; + // t->func[t->reentrancy] = func; + // t->thread[t->reentrancy] = pthread_self(); + // t->reentrancy++; + //} else { + // __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", + // filename, lineno, func, mutex_name); + //} } return res; @@ -506,26 +514,26 @@ } #endif - if (t->reentrancy && (t->thread[t->reentrancy-1] != pthread_self())) { - __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", - filename, lineno, func, mutex_name); - __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", - t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name); - DO_THREAD_CRASH; - } + //if (t->reentrancy && (t->thread[t->reentrancy-1] != pthread_self())) { + // __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", + // filename, lineno, func, mutex_name); + // __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", + // t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name); + // DO_THREAD_CRASH; + //} - if (--t->reentrancy < 0) { - __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", - filename, lineno, func, mutex_name); - t->reentrancy = 0; - } + //if (--t->reentrancy < 0) { + // __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", + // filename, lineno, func, mutex_name); + // t->reentrancy = 0; + //} - if (t->reentrancy < AST_MAX_REENTRANCY) { - t->file[t->reentrancy] = NULL; - t->lineno[t->reentrancy] = 0; - t->func[t->reentrancy] = NULL; - t->thread[t->reentrancy] = 0; - } + //if (t->reentrancy < AST_MAX_REENTRANCY) { + // t->file[t->reentrancy] = NULL; + // t->lineno[t->reentrancy] = 0; + // t->func[t->reentrancy] = NULL; + // t->thread[t->reentrancy] = 0; + //} if (t->track) ast_remove_lock_info(&t->mutex); @@ -538,16 +546,16 @@ if (t->track) ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); - if (t->reentrancy < AST_MAX_REENTRANCY) { - t->file[t->reentrancy] = filename; - t->lineno[t->reentrancy] = lineno; - t->func[t->reentrancy] = func; - t->thread[t->reentrancy] = pthread_self(); - t->reentrancy++; - } else { - __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", - filename, lineno, func, mutex_name); - } + //if (t->reentrancy < AST_MAX_REENTRANCY) { + // t->file[t->reentrancy] = filename; + // t->lineno[t->reentrancy] = lineno; + // t->func[t->reentrancy] = func; + // t->thread[t->reentrancy] = pthread_self(); + // t->reentrancy++; + //} else { + // __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", + // filename, lineno, func, mutex_name); + //} } return res; @@ -954,3 +962,4 @@ #endif #endif /* _ASTERISK_LOCK_H */ +