diff --git a/configure.in b/configure.in index c1a43ea170..52d884f090 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ # Must change all of the below together # For a release, set revision for that tagged release as well and uncomment -AC_INIT([freeswitch], [1.3.5b], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.3.5], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [3]) -AC_SUBST(SWITCH_VERSION_MICRO, [5b]) +AC_SUBST(SWITCH_VERSION_MICRO, [5]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) diff --git a/src/include/switch_pgsql.h b/src/include/switch_pgsql.h index 00da8efffa..ff4e83f11a 100644 --- a/src/include/switch_pgsql.h +++ b/src/include/switch_pgsql.h @@ -156,6 +156,8 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_callback_exec_detailed SWITCH_DECLARE(char *) switch_pgsql_handle_get_error(switch_pgsql_handle_t *handle); SWITCH_DECLARE(int) switch_pgsql_handle_affected_rows(switch_pgsql_handle_t *handle); +SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_flush(switch_pgsql_handle_t *handle); + SWITCH_END_EXTERN_C #endif diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 7d1e6c8716..b776a14a87 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -293,6 +293,17 @@ SWITCH_DECLARE(void) switch_cache_db_flush_handles(void) SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t **dbh) { if (dbh && *dbh) { + + switch((*dbh)->type) { + case SCDB_TYPE_PGSQL: + { + switch_pgsql_flush((*dbh)->native_handle.pgsql_dbh); + } + break; + default: + break; + } + switch_mutex_lock(sql_manager.dbh_mutex); (*dbh)->last_used = switch_epoch_time_now(NULL); @@ -406,7 +417,7 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h switch (type) { case SCDB_TYPE_PGSQL: { - db_name = connection_options->odbc_options.dsn; + db_name = connection_options->pgsql_options.dsn; odbc_user = NULL; odbc_pass = NULL; } diff --git a/src/switch_pgsql.c b/src/switch_pgsql.c index f326305657..6d6bd656e9 100644 --- a/src/switch_pgsql.c +++ b/src/switch_pgsql.c @@ -276,11 +276,8 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_cancel_real(const char *file, ret = SWITCH_PGSQL_FAIL; } PQfreeCancel(cancel); - { - PGresult *tmp = NULL; - /* Make sure the query is fully cancelled */ - while ((tmp = PQgetResult(handle->con)) != NULL) PQclear(tmp); - } + switch_pgsql_flush(handle); + #endif return ret; } @@ -427,14 +424,13 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsq return SWITCH_PGSQL_SUCCESS; error: - { - PGresult *tmp = NULL; - /* Make sure the failed connection does not have any transactions marked as in progress */ - while ((tmp = PQgetResult(handle->con)) != NULL) PQclear(tmp); - /* Try to reconnect to the DB if we were dropped */ - db_is_up(handle); - } + /* Make sure the failed connection does not have any transactions marked as in progress */ + switch_pgsql_flush(handle); + + /* Try to reconnect to the DB if we were dropped */ + db_is_up(handle); + #endif return SWITCH_PGSQL_FAIL; } @@ -572,6 +568,9 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_exec_base_detailed(con #ifdef SWITCH_HAVE_PGSQL char *err_str = NULL, *er = NULL; + + + switch_pgsql_flush(handle); handle->affected_rows = 0; if (!db_is_up(handle)) { @@ -829,6 +828,29 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_SQLSetAutoCommitAttr(switch_p #endif } +SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_flush(switch_pgsql_handle_t *handle) +{ +#ifdef SWITCH_HAVE_PGSQL + + PGresult *tmp = NULL; + int x = 0; + + /* Make sure the query is fully cleared */ + while ((tmp = PQgetResult(handle->con)) != NULL) { + PQclear(tmp); + x++; + } + + if (x) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Flushing %d results\n", x); + } + + return SWITCH_PGSQL_SUCCESS; +#else + return (switch_pgsql_status_t) SWITCH_FALSE; +#endif +} + SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_SQLEndTran(switch_pgsql_handle_t *handle, switch_bool_t commit) { #ifdef SWITCH_HAVE_PGSQL