[OpenSER-Users] avp_db_query() timeout

Iñaki Baz Castillo ibc at aliax.net
Mon Jan 14 22:46:00 CET 2008


El Lunes, 14 de Enero de 2008, Douglas Garstang escribió:
> I haven't had much luck getting replies to my questions lately, hopefully
> I'll have more luck with this one.
>
> avp_db_query().... does it have a timeout? What is it? Can I set it?
>
> If I use it, and there is a MySQL database problem, I don't want
> avp_db_query() to wait forever trying to connect to MySQL. If it can't
> connect after a few seconds, I'd like it to just give up. I have multiple
> calls to avp_db_query() in a typical call flow. It would be even better if
> I could set a flag on the first timeout and not try again during that call.
>
> Can that be done?

Hi, by the test I've done:

  avp_db_query("SQL_QUERY", "$avp(s:result)");
  xlog("L_INFO", "retcode = $rc \n");

Cases:

- If query doesn't return a row/value then $avp(s:result)=null and $rc=(-1).

- If query returns a row/value the $avp(s_result) stores that value and $rc=1.

- If there is a syntax error in query then $avp(s:result)=null and $rc=(-1).

- If MySQL is not running  then $avp(s:result)=null and $rc=(-1).


I don't know what occurs if MySQL is running but because overload or any other 
reason it doesn't reply, but AFAIK the "avp_db_query" uses the same code of 
other OpenSer functions to access DB, so I'm sure it has a correct behaviour 
in case of failure.

BTW you can "play" with the $rc code after "avp_db_query".





-- 
Iñaki Baz Castillo




More information about the Users mailing list