Compare commits
3 Commits
07a64e10bc
...
85e96b6aac
Author | SHA1 | Date |
---|---|---|
Seven Du | 85e96b6aac | |
Aron Podrigal | 5cb74797fe | |
Seven Du | f0ab438d89 |
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1062,7 +1062,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
|
|||
} else {
|
||||
switch_xml_t x_param, x_params;
|
||||
const char *use_passwd = NULL, *verto_context = NULL, *verto_dialplan = NULL;
|
||||
time_t now = switch_epoch_time_now(NULL);
|
||||
switch_time_t now = switch_epoch_time_now(NULL);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Login sucessful for user: %s domain: %s\n", id, domain);
|
||||
|
||||
|
@ -1117,11 +1117,11 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
|
|||
switch_clear_flag(jsock, JPFLAG_AUTH_EXPIRED);
|
||||
|
||||
if (!strcmp(var, "login-expires")) {
|
||||
uint32_t tmp = atol(val);
|
||||
switch_time_t tmp = atol(val);
|
||||
|
||||
if (tmp > now) {
|
||||
jsock->exptime = tmp;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Login expire time for %s set to %ld seconds [%ld] [%ld]\n", jsock->uid, tmp - now, jsock->exptime, now);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Login expire time for %s set to %" SWITCH_TIME_T_FMT " seconds [%" SWITCH_TIME_T_FMT "] [%" SWITCH_TIME_T_FMT "]\n", jsock->uid, tmp - now, jsock->exptime, now);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid expire time for %s. Defaulting to 300 sec\n", jsock->uid);
|
||||
jsock->exptime = now + 300;
|
||||
|
@ -1994,7 +1994,7 @@ static void client_run(jsock_t *jsock)
|
|||
|
||||
while(jsock->profile->running) {
|
||||
int pflags, poll_time = 50;
|
||||
time_t now;
|
||||
switch_time_t now;
|
||||
|
||||
if (!jsock->ws) { die("%s Setup Error\n", jsock->name); }
|
||||
|
||||
|
@ -2005,9 +2005,8 @@ static void client_run(jsock_t *jsock)
|
|||
|
||||
if (now >= jsock->exptime) {
|
||||
switch_set_flag(jsock, JPFLAG_AUTH_EXPIRED);
|
||||
die("%s Authentication Expired [%ld] >= [%ld]\n", jsock->uid, now, jsock->exptime);
|
||||
die("%s Authentication Expired [%" SWITCH_TIME_T_FMT "] >= [%" SWITCH_TIME_T_FMT "]\n", jsock->uid, now, jsock->exptime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (jsock->drop) { die("%s Dropping Connection\n", jsock->name); }
|
||||
|
|
|
@ -141,8 +141,8 @@ struct jsock_s {
|
|||
char remote_host[256];
|
||||
int remote_port;
|
||||
int family;
|
||||
time_t exptime;
|
||||
time_t logintime;
|
||||
switch_time_t exptime;
|
||||
switch_time_t logintime;
|
||||
struct verto_profile_s *profile;
|
||||
switch_thread_rwlock_t *rwlock;
|
||||
|
||||
|
@ -191,7 +191,7 @@ typedef struct verto_pvt_s {
|
|||
switch_media_handle_t *smh;
|
||||
switch_core_media_params_t *mparams;
|
||||
switch_call_cause_t remote_hangup_cause;
|
||||
time_t detach_time;
|
||||
switch_time_t detach_time;
|
||||
struct verto_pvt_s *next;
|
||||
switch_byte_t text_read_frame_data[SWITCH_RTP_MAX_BUF_LEN];
|
||||
switch_frame_t text_read_frame;
|
||||
|
|
Loading…
Reference in New Issue