]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
minor fix for deadlock detection, but I hope nobody has to use it :) (bug #3531)
authorRussell Bryant <russell@russellbryant.com>
Sun, 13 Feb 2005 23:43:58 +0000 (23:43 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sun, 13 Feb 2005 23:43:58 +0000 (23:43 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@5025 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/lock.h

index 059bc89c6cd8d82e612e82977510a1206553ce91..350ea88226090e0439f256e8365c0a281cd5a78f 100755 (executable)
@@ -188,17 +188,19 @@ static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *fun
                        filename, lineno, func, mutex_name);
 #endif
                ast_mutex_init(t);
-        }
+       }
 #endif /* definded(AST_MUTEX_INIT_W_CONSTRUCTORS) || defined(AST_MUTEX_INIT_ON_FIRST_USE) */
 #ifdef DETECT_DEADLOCKS
        {
-               time_t seconds seconds = time(NULL);
+               time_t seconds = time(NULL);
+               time_t current;
                do {
                        res = pthread_mutex_trylock(&t->mutex);
                        if (res == EBUSY) {
-                               if ((time(NULL) - seconds) % 5) {
+                               current = time(NULL);
+                               if ((current - seconds) && (!((current - seconds) % 5))) {
                                        fprintf(stderr, "%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
-                                               filename, lineno, func, (time(NULL) - seconds), mutex_name);
+                                               filename, lineno, func, (int)(current - seconds), mutex_name);
                                        fprintf(stderr, "%s line %d (%s): '%s' was locked here.\n",
                                                t->file, t->lineno, t->func, mutex_name);
                                }