[Home]

Summary:ASTERISK-09296: cna_modem thread freeze in restart_monitor() function.
Reporter:Alain Degreffe (ecze)Labels:
Date Opened:2007-04-23 02:41:20Date Closed:2007-04-24 12:44:18
Priority:BlockerRegression?No
Status:Closed/CompleteComponents:Channels/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Hi, here is the cade that block the thread.
I try to use this old deprecated channel but since ? modification in the repository (http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_modem.c?r1=7221&r2=9404), the restart_monitor() just wait indefinitely....


static int restart_monitor()
{
       /* If we're supposed to be stopped -- stay stopped */
       if (monitor_thread == AST_PTHREADT_STOP)
               return 0;
       if (ast_mutex_lock(&monlock)) {
               ast_log(LOG_WARNING, "Unable to lock monitor\n");
               return -1;
       }
       if (monitor_thread == pthread_self()) {
               ast_mutex_unlock(&monlock);
               ast_log(LOG_WARNING, "Cannot kill myself\n");
               return -1;
       }
       if (monitor_thread != AST_PTHREADT_NULL) {
               pthread_kill(monitor_thread, SIGURG);
               pthread_join(monitor_thread, NULL);
       } else {
               /* Start a new monitor */
               if (ast_pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) {
                       ast_mutex_unlock(&monlock);
                       ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
                       return -1;
               }
       }
       ast_mutex_unlock(&monlock);
       return 0;
}



The problem is here:

       .......  
       if (monitor_thread != AST_PTHREADT_NULL) {
               pthread_kill(monitor_thread, SIGURG);
               pthread_join(monitor_thread, NULL);
       } else {
       .......


pthread_join is waiting for the thread termination but it never happens ! Thre is no reason for that because pthread_kill will not kill the thread but just send a URGENT signal to the thread.

By removing the pthread_join(), the function work normally....

Am I right or not ?

PS: I currently test this modification and it seems to work...

       if (monitor_thread != AST_PTHREADT_NULL) {
               pthread_kill(monitor_thread, SIGURG);
               // pthread_join(monitor_thread, NULL);
       } else {

Alain
Comments:By: Alain Degreffe (ecze) 2007-04-23 04:28:46

Sorry for the title... It must be changed to chan_modem thread freeze in restart_monitor() function.