aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-14 01:25:36 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-14 01:25:36 +0000
commit3b2aaf764626c8870fd2c7de8805fb935e65b0db (patch)
tree4d30def0ed9f0474daecbf66e9c3c90cc3cc19f3 /include
parent6876fa7e1d6a27bfb5f311cc6d30aa4e56f00648 (diff)
Merged revisions 92875 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r92875 | mmichelson | 2007-12-13 19:24:06 -0600 (Thu, 13 Dec 2007) | 7 lines When compiling with DETECT_DEADLOCKS, don't spam the CLI with messages about possible deadlocks. Instead just print the intended single message every five seconds. (closes issue 11537, reported and patched by dimas) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@92876 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/lock.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 3695d23a7..f9a6a5831 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -329,7 +329,7 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con
#ifdef DETECT_DEADLOCKS
{
time_t seconds = time(NULL);
- time_t current;
+ time_t wait_time, reported_wait = 0;
do {
#ifdef HAVE_MTX_PROFILE
ast_mark(mtx_prof, 1);
@@ -339,15 +339,16 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con
ast_mark(mtx_prof, 0);
#endif
if (res == EBUSY) {
- current = time(NULL);
- if ((current - seconds) && (!((current - seconds) % 5))) {
+ wait_time = time(NULL) - seconds;
+ if (wait_time > reported_wait && (wait_time % 5) == 0) {
__ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
- filename, lineno, func, (int)(current - seconds), mutex_name);
+ filename, lineno, func, (int) wait_time, mutex_name);
ast_reentrancy_lock(t);
__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_reentrancy_unlock(t);
+ reported_wait = wait_time;
}
usleep(200);
}