[asterisk-dev] tilghman: branch 1.4 r152958 - /branches/1.4/channels/chan_h323.c

Russell Bryant russell at digium.com
Thu Oct 30 15:40:25 CDT 2008


SVN commits to the Digium repositories wrote:
> Author: tilghman
> Date: Thu Oct 30 15:33:28 2008
> New Revision: 152958
> 
> URL: http://svn.digium.com/view/asterisk?view=rev&rev=152958
> Log:
> Cannot join detached threads.  See http://www.opengroup.org/onlinepubs/000095399/functions/pthread_join.html
> (Closes issue #13400)
> 
> Modified:
>     branches/1.4/channels/chan_h323.c
> 
> Modified: branches/1.4/channels/chan_h323.c
> URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_h323.c?view=diff&rev=152958&r1=152957&r2=152958
> ==============================================================================
> --- branches/1.4/channels/chan_h323.c (original)
> +++ branches/1.4/channels/chan_h323.c Thu Oct 30 15:33:28 2008
> @@ -3226,11 +3226,12 @@
>  	}
>  	if (!ast_mutex_lock(&monlock)) {
>  		if ((monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {
> -			/* this causes a seg, anyone know why? */
> -			if (monitor_thread != pthread_self())
> +			if (monitor_thread != pthread_self()) {
>  				pthread_cancel(monitor_thread);
> +			}
>  			pthread_kill(monitor_thread, SIGURG);
> -			pthread_join(monitor_thread, NULL);
> +			/* Cannot join detached threads */
> +			/* pthread_join(monitor_thread, NULL); */
>  		}
>  		monitor_thread = AST_PTHREADT_STOP;
>  		ast_mutex_unlock(&monlock);

Perhaps a better fix for this is to not create the tread as detached. 
As it stands, AFAICS, the code is doing thing to ensure that the thread 
stops running before it continues on destroying data that the monitor 
thread uses and then being unloaded.  This is going to lead to crashes.

-- 
Russell Bryant
Senior Software Engineer
Open Source Team Lead
Digium, Inc.



More information about the asterisk-dev mailing list