[OpenSIPS-Users] global variables

Bogdan-Andrei Iancu bogdan at voice-system.ro
Tue Mar 9 10:05:54 CET 2010


Hi Josip,

Josip Djuricic wrote:
> Hi,
>
> one probably stupid question, I'm customizing siptrace module further,
> so I am adding queue for db writing, in case we loose db connectivity
> and threads for popping the queue and writing to db.
>   
why don't you use the new db_virtual module with a failover 
configuration: define a new virtual db connection that has behind a 
primary mysql conn and a secondary (failover only) flatstore/dbtext 
conn. So, if DB fails, you will start writing to a local file.
> Written almost everything, but just to be sure, if I use global variable
> for linked list, will they keep the values until opensips ends, or will
> they always be reinitialized, because for test purposes I defined
> counter but it's always initialized to default value.
>   
To be honest I do not advices using thread in current opensips as you 
have multiple processes already. And the combination of threads and 
processes may be unpredictable.
Anyhow, regarding your question - the global vars are init only at 
startup time - but note that "global" is as visibility in the code and 
not global "in all processes". Each process will have its own copy of 
the var.

Regards,
Bogdan

-- 
Bogdan-Andrei Iancu
www.voice-system.ro




More information about the Users mailing list