Are globals thread-safe?


Does someone know whether Asterisk’s global variables are thread-safe?

I wish to read and write from within the dialplan and from the outside. The background is that I have a service provider who rotates his proxy servers in the background and doesn’t maintain the state of registrations. New calls may fail with 403 and a couple of other stupid things happen as well. The idea is basically to monitor the priorities of their proxy servers, send an unregister followed by a register when there are no ongoing calls and block new calls with a global variable which is supposed to act as a flag. The process of registration may take a few seconds, so I need to signal the current state. Not perfect, but could make life a bit easier.

They can be accessed and manipulated by multiple things at once, yes, but they are not locked. That is: A write followed by a read may produce a different result than what was written if something in between altered it.

Deleted. Wrong conclusion based on finding very old copy of source file.

There is a lock held internally during that time, so you can’t read in between the delete and add.

Sorry, you are right. I found a very old version when searching by function name.

Understood and I can live with the restriction as there are at most 2 alterations per hour. I think this approach still reduces the number of failed calls.

BTW, thank you for solving the login issue.