Since this banch only is for debugging the chan_lcr deadlock problem, i will commit...
[lcr.git] / chan_lcr.c
index 38f969b..88f6670 100644 (file)
@@ -254,8 +254,9 @@ void chan_lcr_log(int type, const char *file, int line, const char *function, st
        if (ast)
                strncpy(ast_text, ast->name, sizeof(ast_text)-1);
        ast_text[sizeof(ast_text)-1] = '\0';
-       
-       ast_log(type, file, line, function, "[call=%s ast=%s] %s", call_text, ast_text, buffer);
+
+printf("\n[call=%s ast=%s] %s\n", call_text, ast_text, buffer);
+//     ast_log(type, file, line, function, "[call=%s ast=%s] %s", call_text, ast_text, buffer);
 
        ast_mutex_unlock(&log_lock);
        lock_debug("l");
@@ -1686,13 +1687,22 @@ static void handle_queue()
        struct ast_frame fr;
        char *p;
 
+again:
        call = call_first;
        while(call) {
                p = call->queue_string;
                ast = call->ast;
                if (*p && ast) {
                        lock_debug("A1+");
-//                     ast_channel_lock(ast);
+                       if (ast_channel_trylock(ast)) {
+                               lock_debug("<trylock failed>");
+                               ast_mutex_unlock(&chan_lock);
+                               usleep(1000);
+                               lock_debug("A1++");
+                               ast_mutex_lock(&chan_lock);
+                               lock_debug("A1+-");
+                               goto again;
+                       }
                        lock_debug("A1-");
                        while(*p) {
                                switch (*p) {
@@ -1749,7 +1759,7 @@ static void handle_queue()
                                p++;
                        }
                        call->queue_string[0] = '\0';
-//                     ast_channel_unlock(ast);
+                       ast_channel_unlock(ast);
                        lock_debug("a1");
                }
                call = call->next;
@@ -2015,8 +2025,8 @@ static void send_digit_to_chan(struct ast_channel * ast, char digit )
                 ast_playtones_start(ast,0,dtmf_tones[15], 0);
         else {
                 /* not handled */
-                ast_log(LOG_DEBUG, "Unable to handle DTMF tone "
-                       "'%c' for '%s'\n", digit, ast->name);
+//                ast_log(LOG_DEBUG, "Unable to handle DTMF tone "
+//                     "'%c' for '%s'\n", digit, ast->name);
         }
 }