Compare commits

...

6 Commits

Author SHA1 Message Date
Minh c850dc5c9d
Merge 2778d451c2 into 5cb74797fe 2025-01-17 16:41:39 +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
Minh 2778d451c2
Merge branch 'master' into log-esl-command-option 2024-12-06 16:05:00 +01:00
Minh c0cf399007
Merge branch 'master' into log-esl-command-option 2024-12-03 22:27:48 +01:00
Minh Minh dd53129f28 typo 2024-11-27 22:56:33 +01:00
Minh Minh b181f0c472 log received esl command capability 2024-11-27 22:31:13 +01:00
3 changed files with 37 additions and 1 deletions

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;
}

View File

@ -4,6 +4,8 @@
<param name="listen-ip" value="127.0.0.1"/>
<param name="listen-port" value="8021"/>
<param name="password" value="ClueCon"/>
<!-- Log the command that freeswitch received; default is false -->
<param name="log-recv-cmd" value="true"/>
<!--<param name="apply-inbound-acl" value="lan"/>-->
</settings>
</configuration>

View File

@ -108,6 +108,7 @@ static struct {
switch_mutex_t *listener_mutex;
switch_event_node_t *node;
int debug;
int log_recv_cmd;
} globals;
static struct {
@ -1726,6 +1727,10 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
goto done;
}
if (globals.log_recv_cmd > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Received from %s:%d: %s", listener->remote_ip, listener->remote_port, cmd);
}
if (switch_stristr("unload", cmd) && switch_stristr("mod_event_socket", cmd)) {
cmd = unload_cheat;
} else if (switch_stristr("reload", cmd) && switch_stristr("mod_event_socket", cmd)) {
@ -2887,6 +2892,8 @@ static int config(void)
set_pref_ip(val);
} else if (!strcmp(var, "debug")) {
globals.debug = atoi(val);
} else if (!strcmp(var, "log-recv-cmd")) {
globals.log_recv_cmd = switch_true(val) ? 1 : 0;
} else if (!strcmp(var, "nat-map")) {
if (switch_true(val) && switch_nat_get_type()) {
prefs.nat_map = 1;