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

wdoekes reviewboard at asterisk.org
Sat Feb 8 01:40:03 CST 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/3201/
-----------------------------------------------------------

Review request for Asterisk Developers and Julian Lyndon-Smith.


Repository: Asterisk


Description
-------

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:

  va_start(ap);
  lookup_fields = realtime_arguments_to_fields(ap);
  update_fields = realtime_arguments_to_fields(ap);
  va_end(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.


Diffs
-----

  /branches/12/main/config.c 406079 

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


Testing
-------

It compiles.

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

Waiting on jmls to confirm that this patch fixes his problem.


Thanks,

wdoekes

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140208/dea95b83/attachment-0001.html>


More information about the asterisk-dev mailing list