Compare commits

...

10 Commits

Author SHA1 Message Date
wmasilva 50b8f56e36
Merge ddb8018041 into 5cb74797fe 2025-01-17 16:40:19 +00:00
Aron Podrigal 5cb74797fe
[mod_pgsql] err is now set correctly (dbh:last_error())
New function, `void pgsql_handle_set_error_if_not_set(switch_pgsql_handle_t *handle, char **err)` has been added to mod_pgsql module. This function is now called at several points where an error occurred but *err was not yet set.
2025-01-17 18:51:45 +03:00
wmasilva ddb8018041
Merge branch 'signalwire:master' into mod_callcenter-fix-callcenter_track_single_agent 2023-04-11 10:14:37 +01:00
António Silva 2cf7d943aa Merge branch 'mod_callcenter-fix-callcenter_track_single_agent' of https://github.com/wmasilva/freeswitch into mod_callcenter-fix-callcenter_track_single_agent 2021-02-08 16:28:58 +00:00
Antonio Silva ea117fb064 mod_callcenter: track agent fix missing new line in log 2021-02-08 16:28:43 +00:00
Antonio Silva ed206b07e7 mod_callcenter: fix tracking agent external calls - prevent multiple track per channel 2021-02-08 16:28:42 +00:00
Antonio Silva a4c657f0b1 mod_callcenter: track agent fix missing new line in log 2020-05-08 16:29:27 +02:00
Antonio Silva 269d63d222 Merge branch 'mod_callcenter-fix-callcenter_track_single_agent' of https://github.com/wmasilva/freeswitch into mod_callcenter-fix-callcenter_track_single_agent 2020-05-08 15:36:23 +02:00
Antonio Silva b69853c1ad mod_callcenter: fix tracking agent external calls - prevent multiple track per channel 2020-05-08 15:36:10 +02:00
Antonio Silva 023c77eb63 mod_callcenter: fix tracking agent external calls - prevent multiple track per channel 2020-05-07 17:52:06 +02:00
2 changed files with 38 additions and 5 deletions

View File

@ -3331,10 +3331,10 @@ static switch_status_t cc_hook_state_run(switch_core_session_t *session)
char *sql = NULL;
agent_name = switch_channel_get_variable(channel, "cc_tracked_agent");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Called cc_hook_hanguphook channel %s with state %s", switch_channel_get_name(channel), switch_channel_state_name(state));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Called cc_hook_hanguphook channel '%s' with state '%s' \n", switch_channel_get_name(channel), switch_channel_state_name(state));
if (state == CS_HANGUP) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Tracked call for agent %s ended, decreasing external_calls_count", agent_name);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Tracked call for agent '%s' ended, decreasing external_calls_count \n", agent_name);
sql = switch_mprintf("UPDATE agents SET external_calls_count = external_calls_count - 1 WHERE name = '%q'", agent_name);
cc_execute_sql(NULL, sql, NULL);
switch_safe_free(sql);
@ -3351,6 +3351,7 @@ SWITCH_STANDARD_APP(callcenter_track)
char agent_status[255];
char *agent_name = NULL;
char *sql = NULL;
const char *tracked_agent = NULL;
if (zstr(data)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing agent name\n");
@ -3358,7 +3359,12 @@ SWITCH_STANDARD_APP(callcenter_track)
}
if (cc_agent_get("status", data, agent_status, sizeof(agent_status)) != CC_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Invalid agent %s", data);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Invalid agent '%s' \n", data);
return;
}
if ((tracked_agent = switch_channel_get_variable(channel, "cc_tracked_agent"))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Already tracking agent '%s' in this channel. \n", tracked_agent);
return;
}
@ -3372,7 +3378,7 @@ SWITCH_STANDARD_APP(callcenter_track)
switch_core_event_hook_add_state_run(session, cc_hook_state_run);
PROTECT_INTERFACE(app_interface);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Tracking this call for agent %s", data);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Tracking this call for agent '%s' \n", data);
switch_safe_free(agent_name);
return;

View File

@ -106,6 +106,22 @@ char * pgsql_handle_get_error(switch_pgsql_handle_t *handle)
return err_str;
}
void pgsql_handle_set_error_if_not_set(switch_pgsql_handle_t *handle, char **err)
{
char *err_str;
if (err && !(*err)) {
err_str = pgsql_handle_get_error(handle);
if (zstr(err_str)) {
switch_safe_free(err_str);
err_str = strdup((char *)"SQL ERROR!");
}
*err = err_str;
}
}
static int db_is_up(switch_pgsql_handle_t *handle)
{
int ret = 0;
@ -553,8 +569,15 @@ switch_status_t pgsql_handle_exec_detailed(const char *file, const char *func, i
goto error;
}
return pgsql_finish_results(handle);
if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
goto error;
}
return SWITCH_STATUS_SUCCESS;
error:
pgsql_handle_set_error_if_not_set(handle, err);
return SWITCH_STATUS_FALSE;
}
@ -630,6 +653,7 @@ done:
pgsql_free_result(&result);
if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
pgsql_handle_set_error_if_not_set(handle, err);
sstatus = SWITCH_STATUS_FALSE;
}
@ -638,6 +662,7 @@ done:
error:
pgsql_free_result(&result);
pgsql_handle_set_error_if_not_set(handle, err);
return SWITCH_STATUS_FALSE;
}
@ -1050,6 +1075,8 @@ switch_status_t pgsql_handle_callback_exec_detailed(const char *file, const char
return SWITCH_STATUS_SUCCESS;
error:
pgsql_handle_set_error_if_not_set(handle, err);
return SWITCH_STATUS_FALSE;
}