[asterisk-dev] [Code Review] Fix reconnecting to pgsql database after connection loss.

rmudgett reviewboard at asterisk.org
Fri Feb 10 18:05:47 CST 2012


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

Review request for Asterisk Developers and Matt Jordan.


Summary
-------

Fix reconnecting to pgsql database after connection loss.

There can only be one database connection in res_config_pgsql just like
res_config_sqlite.  If the connection is lost, the connection may not get
reestablished to the same database if the res_pgsql.conf and
extconfig.conf files are inconsistent.

* Made only use the configured database from res_pgsql.conf.

* Fixed potential buffer overwrite of last[] in config_pgsql().


Rationale for using the original reporter's approach as a base for this
patch:

The way the code in res_config_psql is written is biased toward only one
connection to the database.  That connection is the one specified in
res_pgsql.conf.

1) The pgsql_reconnect() function will not change the open connection if
the supplied database name differs from the name used to open the current
link.  It will only open a link if the current link is either not open or
broken.

2) The CLI "realtime show pgsql status" command only uses the res_pgsql.conf
database name.

3) The CLI "realtime show pgsql cache <table>" command only uses the
res_pgsql.conf database if the table actually isn't cached already.


This addresses bug ASTERISK-16982.
    https://issues.asterisk.org/jira/browse/ASTERISK-16982


Diffs
-----

  branches/1.8/res/res_config_pgsql.c 354890 

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


Testing
-------

This is based off of the approach of the original reporter's patch.


Thanks,

rmudgett

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120211/78634efb/attachment.htm>


More information about the asterisk-dev mailing list