[asterisk-bugs] [JIRA] (ASTERISK-28435) cdr_pgsql: Unix socket doesn't work
Dmitry Svyatogorov (JIRA)
noreply at issues.asterisk.org
Mon Jun 3 09:13:47 CDT 2019
Dmitry Svyatogorov created ASTERISK-28435:
---------------------------------------------
Summary: cdr_pgsql: Unix socket doesn't work
Key: ASTERISK-28435
URL: https://issues.asterisk.org/jira/browse/ASTERISK-28435
Project: Asterisk
Issue Type: Bug
Security Level: None
Components: CDR/cdr_pgsql
Affects Versions: 16.3.0
Reporter: Dmitry Svyatogorov
After refactoring, function pgsql_reconnect() does "ast_str_set()" with statically composed string:
{code}
ast_str_set(&conn_info, 0, "host=%s port=%s dbname=%s user=%s"
{code}
It results in error while trying to connect to unix socket (empty host and port in config), so it's a regression.
I propose the simple check:
{code}
static void pgsql_reconnect(void)
...
if (!strcmp(pghostname, "")) {
// UNIX socket
ast_str_set(&conn_info, 0, "dbname=%s user=%s",
pgdbname, pgdbuser);
} else {
// IP socket
ast_str_set(&conn_info, 0, "host=%s port=%s dbname=%s user=%s",
pghostname, pgdbport, pgdbname, pgdbuser);
}
{code}
This patch works for me. _But m.b. there is more clear way?_
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list