[asterisk-dev] [Code Review] 3201: realtime: Fix ast_update2_realtime() on raspberry pi.

wdoekes reviewboard at asterisk.org
Wed Feb 12 02:38:10 CST 2014

This is an automatically generated e-mail. To reply, visit:

(Updated Feb. 12, 2014, 8:38 a.m.)


This change has been marked as submitted.

Review request for Asterisk Developers and Julian Lyndon-Smith.

Repository: Asterisk


jmls got the following odd query on his raspberry PI:

  [Feb  7 08:36:59] ERROR[3516][C-00000029]: res_config_pgsql.c:167 _pgsql_exec:
  PostgreSQL RealTime: Query Failed:

  UPDATE h42_voicemail SET context='f5f985...', mailbox='502'
  WHERE                    context='f5f985...' AND mailbox='502'

Notice how that is essentially a no-op.

The cause turned out to be this asterisk 12 code in main/config.c:

  lookup_fields = realtime_arguments_to_fields(ap);
  update_fields = realtime_arguments_to_fields(ap);

According to the va_arg manpage, the behaviour of 'ap' after function return is undefined.
In the raspberry case, it was reset, so jmls would get the "lookup fields" twice and never
the "update fields" (the password).

This patch:

- Surrounds both realtime_argument_to_fields calls with a matching va_start+va_end (legal,
  according to man).
- Adds a skip parameter to realtime_arguments_to_fields2(ap, skip), so we can skip past the
  first arguments on the second call.
- Adds a bunch of early returns for cases when ast_variable_new fails (out of mem?) so the
  realtime implementations won't have to crash.


  /branches/12/main/config.c 406079 

Diff: https://reviewboard.asterisk.org/r/3201/diff/


It compiles.

jmls confirmed that the second call using 'ap' yielded the first result set, instead of the expected second.

jmls confirmed that the patch fixes his problem.

  10:14 <jmls> meh - doesn't look like I have access to the reviewboard ..
  10:38 <jmls> but can confirm that the password update now works just fine



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140212/255d5350/attachment.html>

More information about the asterisk-dev mailing list