On Sunday 07 October 2007 14:38, Corrado Santoro wrote: > I'm writing an Asterisk application and, for some reason, I need to > access the same "ast_channel" from two different threads: one thread > basically executes "ast_waitfor_nandfds" and the other thread "ast_write". > > So I would like to ask if the access to the channel is thread-safe, or I > need e.g. a mutex to avoid inconsistencies.
You need to lock and hold the chan->lock mutex for any period that you access and/or change channel structure elements. Note that if you access more than one channel lock at a time, you may need to use ast_mutex_trylock() in a loop to avoid possible deadlocks (since there is no locking order for different channels in place). -- Tilghman _______________________________________________ --Bandwidth and Colocation Provided by http://www.api-digital.com-- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev
