Compare commits
3 Commits
cc98100443
...
af7abd0551
Author | SHA1 | Date |
---|---|---|
İlkay Orhanlar | af7abd0551 | |
Aron Podrigal | 5cb74797fe | |
ilkay.orhanlar | 56fa1140e2 |
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -340,6 +340,8 @@ static switch_status_t load_profile(switch_xml_t xml)
|
|||
switch_xml_t param, settings;
|
||||
char *name = (char *) switch_xml_attr_soft(xml, "name");
|
||||
logfile_profile_t *new_profile;
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
char *filename_to_check = NULL;
|
||||
|
||||
new_profile = switch_core_alloc(module_pool, sizeof(*new_profile));
|
||||
memset(new_profile, 0, sizeof(*new_profile));
|
||||
|
@ -383,6 +385,18 @@ static switch_status_t load_profile(switch_xml_t xml)
|
|||
new_profile->logfile = strdup(logfile);
|
||||
}
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
filename_to_check = switch_core_alloc(pool, strlen(new_profile->logfile) + WARM_FUZZY_OFFSET);
|
||||
for(unsigned int i=1; i<new_profile->max_rot; i++) {
|
||||
sprintf(filename_to_check, "%s.%i", new_profile->logfile, i);
|
||||
if (switch_file_exists(filename_to_check, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
new_profile->suffix = i+1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
|
||||
if (mod_logfile_openlogfile(new_profile, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue