[sr-dev] Reseting a pseudo-variable for each new request/response

Iñaki Baz Castillo ibc at aliax.net
Mon Oct 4 19:38:54 CEST 2010


Hi, in a module I'm writting I export a script function which gives
value to a new pseudo-variable. This pv is stored in a global variable
into each worker process.

I don't know how to solve this issue:

- A request is handled by worker-1.
- The script calls to the module function so the pv is filled (it's
value is stored in a global str within the process).
- Later in the script I can access to $new_pv (it reads the global str
in the pv_get_new_pv() function).
- The request processing ends (i.e: t_relay).
- After some time the same worker-1 receives a new request.
- If the script reads $new_pv (without calling the module function
before) it will get the value generated during the previous SIP
request.

Of course the script configuration shouldn't try to read $new_pv
without calling first to the exported function, but anyhow this could
happen (due to a bad script file). Is there an ellegant way to avoid
this? This is, I would like that when a process receives a request (or
a response) $new_pv gets automatically reseted (to NULL), prior to
executing the script logic. In this way accessing to $new_pv without
calling the module function would return an empty value.

Is it possible? how do other modules handle this case?

Thanks a lot.

-- 
Iñaki Baz Castillo
<ibc at aliax.net>



More information about the sr-dev mailing list