[asterisk-bugs] [JIRA] Closed: (ASTERISK-19991) Memory leak in cel_pgsql
Digium Subversion (JIRA)
noreply at issues.asterisk.org
Tue Sep 4 21:21:07 CDT 2012
[ https://issues.asterisk.org/jira/browse/ASTERISK-19991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Digium Subversion closed ASTERISK-19991.
----------------------------------------
Resolution: Fixed
> Memory leak in cel_pgsql
> ------------------------
>
> Key: ASTERISK-19991
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-19991
> Project: Asterisk
> Issue Type: Bug
> Security Level: None
> Components: CEL/cel_pgsql
> Affects Versions: 1.8.13.0
> Reporter: Etienne Lessard
> Attachments: mem_leak_cel_pgsql.patch
>
>
> There's a memory leak in cel_pgsql that happens every time a CEL is successfully written to postgres.
> This happens in this piece of code:
> {code}
> [...]
> result = PQexec(conn, ast_str_buffer(sql));
> if (PQresultStatus(result) != PGRES_COMMAND_OK) {
> pgerror = PQresultErrorMessage(result);
> ast_log(LOG_WARNING, "Failed to insert call detail record into database!\n");
> ast_log(LOG_WARNING, "Reason: %s\n", pgerror);
> ast_log(LOG_WARNING, "Connection may have been lost... attempting to reconnect.\n");
> PQreset(conn);
> if (PQstatus(conn) == CONNECTION_OK) {
> ast_log(LOG_NOTICE, "Connection reestablished.\n");
> connected = 1;
> PQclear(result);
> result = PQexec(conn, ast_str_buffer(sql));
> if (PQresultStatus(result) != PGRES_COMMAND_OK) {
> pgerror = PQresultErrorMessage(result);
> ast_log(LOG_ERROR, "HARD ERROR! Attempted reconnection failed. DROPPING CALL RECORD!\n");
> ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
> }
> }
> PQclear(result);
> goto ast_log_cleanup;
> }
> ast_log_cleanup:
> ast_free(sql);
> ast_free(sql2);
> }
> ast_mutex_unlock(&pgsql_lock);
> }
> {code}
> As you can see, PQclear(result) will not be called when PQresultStatus(result) == PGRES_COMMAND_OK, thus causing a leak. We have patched the module and ran 35 000 calls and the leak that we observed earlier disappeared.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the asterisk-bugs
mailing list