[asterisk-dev] Help, can't get out of while loop

Dennis Buteyn dennis.buteyn at xorcom.com
Thu Jan 14 02:29:52 CST 2021


That loop is equivalent to:

audiohook->status = AST_AUDIOHOOK_STATUS_SHUTDOWN;
while (audiohook->status != AST_AUDIOHOOK_STATUS_DONE) {
     sleep(...);
}

Something else (in another thread) must change the status in order for 
that loop to terminate.

Side note: that struct member probably should be marked volatile, I can 
imagine very eager compilers assuming that status never changes and 
optimizing that code into a real infinite loop.

Dennis Buteyn
Xorcom Ltd

On 1/14/21 10:00 AM, Killian Matter wrote:
> Hello ,
>
> I'm developing a module on asterisk, while debugging i've come across 
> a problem I don't quite understand.
> I'm using a noise filter, at the end of the call I stop my filter , so 
> clean up everything, detach the audiohook and there is the problem. 
> It's stuck in the while loop in *ast_audiohook_detach*.
> As far as I understand, to detach audiohook, the status should not be 
> *NEW* nor *DONE*, then it's update its status to *SHUTDOWN* which will 
> then put it to *DONE*, so why does it get stuck in the while loop and 
> don't update it's status to *DONE* ?
>
> Thank you in advance for your help.
> K.M
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20210114/049ecf57/attachment.html>


More information about the asterisk-dev mailing list