[core] Coverity fixes
* [core] Coverity 1518099, 1518097, 1518098 (Unchecked return value from library) * [core] Coverity 1468551 Unchecked return value * [core] Coverity 1468293 Unchecked return value * [core] Coverity 1468274 Explicit null dereferenced * [core] Coverity 1395588 Unchecked return value * [core] Coverity 1395515 Logically dead code * [core] Coverity 1364984 Result is not floating-point * [core] Coverity 1395554, 1468440 Dereference before null check * [core] Coverity 1024487 Dereference after null check * [core] Coverity 1024872 Unchecked return value * [core] Coverity 1025822 Unchecked return value * [core] Coverity 1025823 Unchecked return value * [core] Coverity 1087637, 1346467, 1087638 Unchecked return value * [core] Coverity 1107607 Unchecked return value * [core] Coverity 1210777 Unchecked return value * [core] Coverity 1227670 Dereference before null check * [core] Coverity 1024551 Logically dead code * [core] Coverity 1024560 Logically dead code * [core] Coverity 1024664 Operands don't affect result * [core] Coverity 1364957 Dereference after null check * [core] Coverity 1395572 Logically dead code * [core] Coverity 1412459 Unchecked return value * [core] Coverity 1412490 Unchecked return value * [core] Coverity 1395515/2 Logically dead code * [core] Coverity cleanup
This commit is contained in:
parent
b6ccc27e6f
commit
bb9afcb388
44
src/cJSON.c
44
src/cJSON.c
|
@ -1104,34 +1104,32 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
|
||||||
buffer->length = default_buffer_size;
|
buffer->length = default_buffer_size;
|
||||||
buffer->format = format;
|
buffer->format = format;
|
||||||
buffer->hooks = *hooks;
|
buffer->hooks = *hooks;
|
||||||
if (buffer->buffer == NULL)
|
|
||||||
{
|
if (buffer->buffer == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print the value */
|
/* print the value */
|
||||||
if (!print_value(item, buffer))
|
if (!print_value(item, buffer)) {
|
||||||
{
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_offset(buffer);
|
update_offset(buffer);
|
||||||
|
|
||||||
/* check if reallocate is available */
|
/* check if reallocate is available */
|
||||||
if (hooks->reallocate != NULL)
|
if (hooks->reallocate != NULL) {
|
||||||
{
|
|
||||||
printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1);
|
printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1);
|
||||||
if (printed == NULL) {
|
if (printed == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->buffer = NULL;
|
buffer->buffer = NULL;
|
||||||
}
|
} else { /* otherwise copy the JSON over to a new buffer */
|
||||||
else /* otherwise copy the JSON over to a new buffer */
|
|
||||||
{
|
|
||||||
printed = (unsigned char*) hooks->allocate(buffer->offset + 1);
|
printed = (unsigned char*) hooks->allocate(buffer->offset + 1);
|
||||||
if (printed == NULL)
|
if (printed == NULL) {
|
||||||
{
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1));
|
memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1));
|
||||||
printed[buffer->offset] = '\0'; /* just to be sure */
|
printed[buffer->offset] = '\0'; /* just to be sure */
|
||||||
|
|
||||||
|
@ -1142,16 +1140,10 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
|
||||||
return printed;
|
return printed;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (buffer->buffer != NULL)
|
if (buffer->buffer != NULL) {
|
||||||
{
|
|
||||||
hooks->deallocate(buffer->buffer);
|
hooks->deallocate(buffer->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printed != NULL)
|
|
||||||
{
|
|
||||||
hooks->deallocate(printed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1942,33 +1934,41 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
|
||||||
|
|
||||||
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
|
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
|
||||||
{
|
{
|
||||||
add_item_to_object(object, string, item, &global_hooks, false);
|
cJSON_bool res = add_item_to_object(object, string, item, &global_hooks, false);
|
||||||
|
(void)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add an item to an object with constant string as key */
|
/* Add an item to an object with constant string as key */
|
||||||
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
|
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
|
||||||
{
|
{
|
||||||
add_item_to_object(object, string, item, &global_hooks, true);
|
cJSON_bool res = add_item_to_object(object, string, item, &global_hooks, true);
|
||||||
|
(void)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
|
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
|
||||||
{
|
{
|
||||||
|
cJSON_bool res;
|
||||||
|
|
||||||
if (array == NULL)
|
if (array == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_item_to_array(array, create_reference(item, &global_hooks));
|
res = add_item_to_array(array, create_reference(item, &global_hooks));
|
||||||
|
(void)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
|
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
|
||||||
{
|
{
|
||||||
|
cJSON_bool res;
|
||||||
|
|
||||||
if ((object == NULL) || (string == NULL))
|
if ((object == NULL) || (string == NULL))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
|
res = add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
|
||||||
|
(void)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
|
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
|
||||||
|
|
|
@ -722,13 +722,10 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
|
||||||
exists = (type == pmap->type && !strcasecmp(name, pmap->iananame) && pmap->pt == pt && (!pmap->rate || rate == pmap->rate) && (!pmap->ptime || pmap->ptime == ptime));
|
exists = (type == pmap->type && !strcasecmp(name, pmap->iananame) && pmap->pt == pt && (!pmap->rate || rate == pmap->rate) && (!pmap->ptime || pmap->ptime == ptime));
|
||||||
break;
|
break;
|
||||||
case SWITCH_MEDIA_TYPE_VIDEO:
|
case SWITCH_MEDIA_TYPE_VIDEO:
|
||||||
if (sdp_type == SDP_TYPE_RESPONSE) {
|
exists = (pmap->sdp_type == SDP_TYPE_REQUEST && type == pmap->type && !strcasecmp(name, pmap->iananame));
|
||||||
exists = (pmap->sdp_type == SDP_TYPE_REQUEST && type == pmap->type && !strcasecmp(name, pmap->iananame));
|
|
||||||
} else {
|
|
||||||
exists = (type == pmap->type && !strcasecmp(name, pmap->iananame));
|
|
||||||
}
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "CHECK PMAP %s:%s %d %s:%s %d ... %d\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "CHECK PMAP %s:%s %d %s:%s %d ... %d\n",
|
||||||
name, sdp_type == SDP_TYPE_REQUEST ? "REQ" : "RES", pt,
|
name, "RES", pt,
|
||||||
pmap->iananame, pmap->sdp_type == SDP_TYPE_REQUEST ? "REQ" : "RES", pmap->pt, exists);
|
pmap->iananame, pmap->sdp_type == SDP_TYPE_REQUEST ? "REQ" : "RES", pmap->pt, exists);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2524,7 +2521,7 @@ static void check_jb_sync(switch_core_session_t *session)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!jb_sync_msec && frames) {
|
if (!jb_sync_msec && frames) {
|
||||||
jb_sync_msec = (double)(1000 / fps) * frames;
|
jb_sync_msec = ((double)1000 / fps) * frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
|
||||||
|
@ -4624,9 +4621,10 @@ static void check_stream_changes(switch_core_session_t *session, const char *r_s
|
||||||
{
|
{
|
||||||
switch_core_session_t *other_session = NULL;
|
switch_core_session_t *other_session = NULL;
|
||||||
switch_core_session_message_t *msg;
|
switch_core_session_message_t *msg;
|
||||||
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
switch_core_session_get_partner(session, &other_session);
|
status = switch_core_session_get_partner(session, &other_session);
|
||||||
|
(void)status;
|
||||||
|
|
||||||
if (switch_channel_test_flag(session->channel, CF_STREAM_CHANGED)) {
|
if (switch_channel_test_flag(session->channel, CF_STREAM_CHANGED)) {
|
||||||
switch_channel_clear_flag(session->channel, CF_STREAM_CHANGED);
|
switch_channel_clear_flag(session->channel, CF_STREAM_CHANGED);
|
||||||
|
@ -4662,13 +4660,15 @@ static void check_stream_changes(switch_core_session_t *session, const char *r_s
|
||||||
if (switch_channel_test_flag(other_session->channel, CF_AWAITING_STREAM_CHANGE)) {
|
if (switch_channel_test_flag(other_session->channel, CF_AWAITING_STREAM_CHANGE)) {
|
||||||
uint8_t proceed = 1;
|
uint8_t proceed = 1;
|
||||||
const char *sdp_in, *other_ep;
|
const char *sdp_in, *other_ep;
|
||||||
|
uint8_t res = 0;
|
||||||
|
|
||||||
if ((other_ep = switch_channel_get_variable(session->channel, "ep_codec_string"))) {
|
if ((other_ep = switch_channel_get_variable(session->channel, "ep_codec_string"))) {
|
||||||
switch_channel_set_variable(other_session->channel, "codec_string", other_ep);
|
switch_channel_set_variable(other_session->channel, "codec_string", other_ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
sdp_in = switch_channel_get_variable(other_session->channel, SWITCH_R_SDP_VARIABLE);
|
sdp_in = switch_channel_get_variable(other_session->channel, SWITCH_R_SDP_VARIABLE);
|
||||||
switch_core_media_negotiate_sdp(other_session, sdp_in, &proceed, SDP_TYPE_REQUEST);
|
res = switch_core_media_negotiate_sdp(other_session, sdp_in, &proceed, SDP_TYPE_REQUEST);
|
||||||
|
(void)res;
|
||||||
switch_core_media_activate_rtp(other_session);
|
switch_core_media_activate_rtp(other_session);
|
||||||
msg = switch_core_session_alloc(other_session, sizeof(*msg));
|
msg = switch_core_session_alloc(other_session, sizeof(*msg));
|
||||||
msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
|
msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
|
||||||
|
@ -13587,6 +13587,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
if (zstr(attr->a_name)) {
|
if (zstr(attr->a_name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(attr->a_name, "ptime")) {
|
if (!strcasecmp(attr->a_name, "ptime")) {
|
||||||
dptime = atoi(attr->a_value);
|
dptime = atoi(attr->a_value);
|
||||||
break;
|
break;
|
||||||
|
@ -13599,22 +13600,27 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
if ((m->m_type == sdp_media_audio || m->m_type == sdp_media_video) && m->m_port) {
|
if ((m->m_type == sdp_media_audio || m->m_type == sdp_media_video) && m->m_port) {
|
||||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
for (attr = m->m_attributes; attr && found < 2; attr = attr->a_next) {
|
for (attr = m->m_attributes; attr && found < 2; attr = attr->a_next) {
|
||||||
if (zstr(attr->a_name)) {
|
if (zstr(attr->a_name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
|
if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
|
||||||
ptime = atoi(attr->a_value);
|
ptime = atoi(attr->a_value);
|
||||||
found++;
|
found++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(attr->a_name, "rtcp-mux")) {
|
if (!strcasecmp(attr->a_name, "rtcp-mux")) {
|
||||||
if (switch_channel_var_true(channel, "rtcp_mux_auto_detect")) {
|
if (switch_channel_var_true(channel, "rtcp_mux_auto_detect")) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "setting rtcp-mux from sdp\n");
|
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "setting rtcp-mux from sdp\n");
|
||||||
switch_channel_set_variable(channel, "rtcp_mux", "true");
|
switch_channel_set_variable(channel, "rtcp_mux", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
found++;
|
found++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_core_media_add_payload_map(session,
|
switch_core_media_add_payload_map(session,
|
||||||
m->m_type == sdp_media_audio ? SWITCH_MEDIA_TYPE_AUDIO : SWITCH_MEDIA_TYPE_VIDEO,
|
m->m_type == sdp_media_audio ? SWITCH_MEDIA_TYPE_AUDIO : SWITCH_MEDIA_TYPE_VIDEO,
|
||||||
map->rm_encoding,
|
map->rm_encoding,
|
||||||
|
@ -13640,11 +13646,13 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
if (zstr(attr->a_name)) {
|
if (zstr(attr->a_name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
|
if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
|
||||||
ptime = atoi(attr->a_value);
|
ptime = atoi(attr->a_value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connection = sdp->sdp_connection;
|
connection = sdp->sdp_connection;
|
||||||
if (m->m_connections) {
|
if (m->m_connections) {
|
||||||
connection = m->m_connections;
|
connection = m->m_connections;
|
||||||
|
@ -13658,7 +13666,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) {
|
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) {
|
||||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||||
|
|
||||||
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
|
if (already_did[map->rm_pt]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13679,19 +13687,20 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
if (match) {
|
if (match) {
|
||||||
add_audio_codec(map, imp, ptime, buf, sizeof(buf));
|
add_audio_codec(map, imp, ptime, buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < num_codecs; i++) {
|
for (i = 0; i < num_codecs; i++) {
|
||||||
const switch_codec_implementation_t *imp = codecs[i];
|
const switch_codec_implementation_t *imp = codecs[i];
|
||||||
|
|
||||||
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO || imp->ianacode > 127 || already_did[imp->ianacode]) {
|
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO || imp->ianacode > 127 || already_did[imp->ianacode]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||||
|
|
||||||
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
|
if (already_did[map->rm_pt]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13724,11 +13733,10 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) {
|
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) {
|
||||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||||
|
|
||||||
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
|
if (already_did[map->rm_pt]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13752,11 +13760,11 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
} else {
|
} else {
|
||||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s", imp->modname, imp->iananame);
|
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s", imp->modname, imp->iananame);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_did[imp->ianacode] = 1;
|
already_did[imp->ianacode] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < num_codecs; i++) {
|
for (i = 0; i < num_codecs; i++) {
|
||||||
const switch_codec_implementation_t *imp = codecs[i];
|
const switch_codec_implementation_t *imp = codecs[i];
|
||||||
|
@ -13772,7 +13780,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
|
|
||||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||||
|
|
||||||
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
|
if (already_did[map->rm_pt]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13793,6 +13801,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
|
||||||
} else {
|
} else {
|
||||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s", imp->modname, imp->iananame);
|
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s", imp->modname, imp->iananame);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_did[imp->ianacode] = 1;
|
already_did[imp->ianacode] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,9 +501,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_destroy_memory_pool(switch_m
|
||||||
#if APR_POOL_DEBUG
|
#if APR_POOL_DEBUG
|
||||||
fspr_pool_destroy_debug(tmp_pool, func);
|
fspr_pool_destroy_debug(tmp_pool, func);
|
||||||
#else
|
#else
|
||||||
fspr_pool_destroy(tmp_pool);
|
if (tmp_pool) {
|
||||||
|
fspr_pool_destroy(tmp_pool);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_MEM_LOCK
|
#ifdef USE_MEM_LOCK
|
||||||
|
|
||||||
switch_mutex_unlock(memory_manager.mem_lock);
|
switch_mutex_unlock(memory_manager.mem_lock);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -2065,6 +2065,7 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm)
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
uint32_t ttl = 0;
|
uint32_t ttl = 0;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
switch_status_t res;
|
||||||
|
|
||||||
if (!zstr(qm->pre_trans_execute)) {
|
if (!zstr(qm->pre_trans_execute)) {
|
||||||
switch_cache_db_execute_sql_real(qm->event_db, qm->pre_trans_execute, &errmsg);
|
switch_cache_db_execute_sql_real(qm->event_db, qm->pre_trans_execute, &errmsg);
|
||||||
|
@ -2126,7 +2127,8 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm)
|
||||||
|
|
||||||
for (i = 0; (qm->max_trans == 0 || ttl <= qm->max_trans) && (i < qm->numq); i++) {
|
for (i = 0; (qm->max_trans == 0 || ttl <= qm->max_trans) && (i < qm->numq); i++) {
|
||||||
switch_mutex_lock(qm->mutex);
|
switch_mutex_lock(qm->mutex);
|
||||||
switch_queue_trypop(qm->sql_queue[i], &pop);
|
res = switch_queue_trypop(qm->sql_queue[i], &pop);
|
||||||
|
(void)res;
|
||||||
switch_mutex_unlock(qm->mutex);
|
switch_mutex_unlock(qm->mutex);
|
||||||
if (pop) break;
|
if (pop) break;
|
||||||
}
|
}
|
||||||
|
@ -2138,6 +2140,7 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm)
|
||||||
switch_mutex_unlock(qm->mutex);
|
switch_mutex_unlock(qm->mutex);
|
||||||
ttl++;
|
ttl++;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_safe_free(pop);
|
switch_safe_free(pop);
|
||||||
if (status != SWITCH_STATUS_SUCCESS) break;
|
if (status != SWITCH_STATUS_SUCCESS) break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2153,7 +2156,6 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
switch(qm->event_db->type) {
|
switch(qm->event_db->type) {
|
||||||
|
@ -2190,11 +2192,11 @@ static uint32_t do_trans(switch_sql_queue_manager_t *qm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch_mutex_lock(qm->mutex);
|
switch_mutex_lock(qm->mutex);
|
||||||
for (i = 0; i < qm->numq; i++) {
|
for (i = 0; i < qm->numq; i++) {
|
||||||
qm->written[i] = qm->pre_written[i];
|
qm->written[i] = qm->pre_written[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_mutex_unlock(qm->mutex);
|
switch_mutex_unlock(qm->mutex);
|
||||||
|
|
||||||
return ttl;
|
return ttl;
|
||||||
|
|
|
@ -98,6 +98,7 @@ SWITCH_DECLARE(Event *) EventConsumer::pop(int block, int timeout)
|
||||||
void *pop = NULL;
|
void *pop = NULL;
|
||||||
Event *ret = NULL;
|
Event *ret = NULL;
|
||||||
switch_event_t *event;
|
switch_event_t *event;
|
||||||
|
switch_status_t res;
|
||||||
|
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -105,14 +106,16 @@ SWITCH_DECLARE(Event *) EventConsumer::pop(int block, int timeout)
|
||||||
|
|
||||||
if (block) {
|
if (block) {
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
switch_queue_pop_timeout(events, &pop, (switch_interval_time_t) timeout * 1000); // millisec rather than microsec
|
res = switch_queue_pop_timeout(events, &pop, (switch_interval_time_t) timeout * 1000); // millisec rather than microsec
|
||||||
} else {
|
} else {
|
||||||
switch_queue_pop(events, &pop);
|
res = switch_queue_pop(events, &pop);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_queue_trypop(events, &pop);
|
res = switch_queue_trypop(events, &pop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)res;
|
||||||
|
|
||||||
if ((event = (switch_event_t *) pop)) {
|
if ((event = (switch_event_t *) pop)) {
|
||||||
ret = new Event(event, 1);
|
ret = new Event(event, 1);
|
||||||
}
|
}
|
||||||
|
@ -138,9 +141,7 @@ SWITCH_DECLARE(void) EventConsumer::cleanup()
|
||||||
|
|
||||||
node_index = 0;
|
node_index = 0;
|
||||||
|
|
||||||
if (events) {
|
switch_queue_interrupt_all(events);
|
||||||
switch_queue_interrupt_all(events);
|
|
||||||
}
|
|
||||||
|
|
||||||
while(switch_queue_trypop(events, &pop) == SWITCH_STATUS_SUCCESS) {
|
while(switch_queue_trypop(events, &pop) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_t *event = (switch_event_t *) pop;
|
switch_event_t *event = (switch_event_t *) pop;
|
||||||
|
|
|
@ -64,6 +64,7 @@ SWITCH_DECLARE(switch_status_t) switch_curl_process_mime(switch_event_t *event,
|
||||||
curl_mime *mime = NULL;
|
curl_mime *mime = NULL;
|
||||||
curl_mimepart *part = NULL;
|
curl_mimepart *part = NULL;
|
||||||
uint8_t added = 0;
|
uint8_t added = 0;
|
||||||
|
switch_CURLcode curl_code = CURLE_OK;
|
||||||
#else
|
#else
|
||||||
struct curl_httppost *formpost=NULL;
|
struct curl_httppost *formpost=NULL;
|
||||||
struct curl_httppost *lastptr=NULL;
|
struct curl_httppost *lastptr=NULL;
|
||||||
|
@ -98,9 +99,21 @@ SWITCH_DECLARE(switch_status_t) switch_curl_process_mime(switch_event_t *event,
|
||||||
|
|
||||||
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
|
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
|
||||||
part = curl_mime_addpart(mime);
|
part = curl_mime_addpart(mime);
|
||||||
curl_mime_name(part, pname);
|
if ((curl_code = curl_mime_name(part, pname))) {
|
||||||
curl_mime_filename(part, fname);
|
free(pname);
|
||||||
curl_mime_filedata(part, hp->value);
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((curl_code = curl_mime_filename(part, fname))) {
|
||||||
|
free(pname);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((curl_code = curl_mime_filedata(part, hp->value))) {
|
||||||
|
free(pname);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
added++;
|
added++;
|
||||||
#else
|
#else
|
||||||
curl_formadd(&formpost,
|
curl_formadd(&formpost,
|
||||||
|
@ -117,8 +130,14 @@ SWITCH_DECLARE(switch_status_t) switch_curl_process_mime(switch_event_t *event,
|
||||||
} else {
|
} else {
|
||||||
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
|
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
|
||||||
part = curl_mime_addpart(mime);
|
part = curl_mime_addpart(mime);
|
||||||
curl_mime_name(part, hp->name);
|
if ((curl_code = curl_mime_name(part, hp->name))) {
|
||||||
curl_mime_data(part, hp->value, CURL_ZERO_TERMINATED);
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((curl_code = curl_mime_data(part, hp->value, CURL_ZERO_TERMINATED))) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
added++;
|
added++;
|
||||||
#else
|
#else
|
||||||
curl_formadd(&formpost,
|
curl_formadd(&formpost,
|
||||||
|
@ -131,6 +150,11 @@ SWITCH_DECLARE(switch_status_t) switch_curl_process_mime(switch_event_t *event,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
|
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
|
||||||
|
error:
|
||||||
|
if (curl_code) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CURL error occured. Error code: %d Error msg: [%s]\n", curl_code, switch_curl_easy_strerror(curl_code));
|
||||||
|
}
|
||||||
|
|
||||||
if (!added) {
|
if (!added) {
|
||||||
curl_mime_free(mime);
|
curl_mime_free(mime);
|
||||||
mime = NULL;
|
mime = NULL;
|
||||||
|
|
|
@ -553,6 +553,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
|
||||||
switch_hash_index_t *hi;
|
switch_hash_index_t *hi;
|
||||||
const void *var;
|
const void *var;
|
||||||
void *val;
|
void *val;
|
||||||
|
switch_status_t res;
|
||||||
|
|
||||||
if (switch_core_test_flag(SCF_MINIMAL)) {
|
if (switch_core_test_flag(SCF_MINIMAL)) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
@ -565,7 +566,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
|
||||||
unsub_all_switch_event_channel();
|
unsub_all_switch_event_channel();
|
||||||
|
|
||||||
if (EVENT_CHANNEL_DISPATCH_QUEUE) {
|
if (EVENT_CHANNEL_DISPATCH_QUEUE) {
|
||||||
switch_queue_trypush(EVENT_CHANNEL_DISPATCH_QUEUE, NULL);
|
res = switch_queue_trypush(EVENT_CHANNEL_DISPATCH_QUEUE, NULL);
|
||||||
|
(void)res;
|
||||||
switch_queue_interrupt_all(EVENT_CHANNEL_DISPATCH_QUEUE);
|
switch_queue_interrupt_all(EVENT_CHANNEL_DISPATCH_QUEUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,10 +575,10 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch queues\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch queues\n");
|
||||||
|
|
||||||
for(x = 0; x < (uint32_t)DISPATCH_THREAD_COUNT; x++) {
|
for(x = 0; x < (uint32_t)DISPATCH_THREAD_COUNT; x++) {
|
||||||
switch_queue_trypush(EVENT_DISPATCH_QUEUE, NULL);
|
res = switch_queue_trypush(EVENT_DISPATCH_QUEUE, NULL);
|
||||||
|
(void)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch_queue_interrupt_all(EVENT_DISPATCH_QUEUE);
|
switch_queue_interrupt_all(EVENT_DISPATCH_QUEUE);
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch threads\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch threads\n");
|
||||||
|
@ -595,6 +597,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
|
||||||
if (THREAD_COUNT == last) {
|
if (THREAD_COUNT == last) {
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
last = THREAD_COUNT;
|
last = THREAD_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1788,6 +1788,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||||
|
|
||||||
if (switch_channel_test_flag(channel, CF_MEDIA_TRANS)) {
|
if (switch_channel_test_flag(channel, CF_MEDIA_TRANS)) {
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
|
|
||||||
return SWITCH_STATUS_INUSE;
|
return SWITCH_STATUS_INUSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1798,6 +1799,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
|
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
|
||||||
|
switch_status_t res = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
/* If we had early media in bypass mode before, it is no longer relevant */
|
/* If we had early media in bypass mode before, it is no longer relevant */
|
||||||
|
@ -1816,6 +1819,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||||
if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't re-establsh media on %s\n", switch_channel_get_name(channel));
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't re-establsh media on %s\n", switch_channel_get_name(channel));
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
|
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1832,7 +1836,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||||
switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
|
switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
|
||||||
switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
|
switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
|
||||||
switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
|
switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
|
||||||
switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
res = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & SMF_REBRIDGE)
|
if ((flags & SMF_REBRIDGE)
|
||||||
|
@ -1844,10 +1848,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||||
switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
|
switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
|
||||||
switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
|
switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
|
||||||
switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
|
switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
|
||||||
switch_core_session_read_frame(other_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
res = switch_core_session_read_frame(other_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||||
switch_channel_clear_state_handler(other_channel, NULL);
|
switch_channel_clear_state_handler(other_channel, NULL);
|
||||||
switch_core_session_rwunlock(other_session);
|
switch_core_session_rwunlock(other_session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)res;
|
||||||
|
|
||||||
if (other_channel) {
|
if (other_channel) {
|
||||||
switch_channel_clear_state_handler(channel, NULL);
|
switch_channel_clear_state_handler(channel, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1862,6 +1869,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||||
} else {
|
} else {
|
||||||
switch_ivr_uuid_bridge(uuid, other_uuid);
|
switch_ivr_uuid_bridge(uuid, other_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
|
switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
|
||||||
switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
|
switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,7 +474,7 @@ static dm_match_t switch_ivr_dmachine_check_match(switch_ivr_dmachine_t *dmachin
|
||||||
|
|
||||||
if (is_timeout) {
|
if (is_timeout) {
|
||||||
if (both_bp) {
|
if (both_bp) {
|
||||||
r_bp = exact_bp ? exact_bp : both_bp;
|
r_bp = exact_bp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4961,9 +4961,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_orig_and_bridge(switch_cor
|
||||||
switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key);
|
switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer_session) {
|
switch_core_session_rwunlock(peer_session);
|
||||||
switch_core_session_rwunlock(peer_session);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
@ -5026,9 +5024,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t
|
||||||
switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key);
|
switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer_session) {
|
switch_core_session_rwunlock(peer_session);
|
||||||
switch_core_session_rwunlock(peer_session);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -3202,6 +3202,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *sess
|
||||||
const char *other_uuid, *moh = NULL;
|
const char *other_uuid, *moh = NULL;
|
||||||
int moh_br = 0;
|
int moh_br = 0;
|
||||||
switch_input_args_t args = { 0 };
|
switch_input_args_t args = { 0 };
|
||||||
|
switch_status_t res;
|
||||||
|
|
||||||
args.input_callback = hold_on_dtmf;
|
args.input_callback = hold_on_dtmf;
|
||||||
args.buf = (void *) unhold_key;
|
args.buf = (void *) unhold_key;
|
||||||
args.buflen = (uint32_t) strlen(unhold_key);
|
args.buflen = (uint32_t) strlen(unhold_key);
|
||||||
|
@ -3232,11 +3234,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *sess
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!zstr(moh) && strcasecmp(moh, "silence")) {
|
if (!zstr(moh) && strcasecmp(moh, "silence")) {
|
||||||
switch_ivr_play_file(session, NULL, moh, &args);
|
res = switch_ivr_play_file(session, NULL, moh, &args);
|
||||||
} else {
|
} else {
|
||||||
switch_ivr_collect_digits_callback(session, &args, 0, 0);
|
res = switch_ivr_collect_digits_callback(session, &args, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)res;
|
||||||
|
|
||||||
if (moh_br) {
|
if (moh_br) {
|
||||||
switch_channel_stop_broadcast(other_channel);
|
switch_channel_stop_broadcast(other_channel);
|
||||||
}
|
}
|
||||||
|
@ -3246,10 +3250,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *sess
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Channel %s is not in a bridge\n", switch_channel_get_name(channel));
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Channel %s is not in a bridge\n", switch_channel_get_name(channel));
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -696,8 +696,11 @@ SWITCH_DECLARE(char *) switch_stun_host_lookup(const char *host, switch_memory_p
|
||||||
{
|
{
|
||||||
switch_sockaddr_t *addr = NULL;
|
switch_sockaddr_t *addr = NULL;
|
||||||
char buf[30];
|
char buf[30];
|
||||||
|
switch_status_t res;
|
||||||
|
|
||||||
|
res = switch_sockaddr_info_get(&addr, host, SWITCH_UNSPEC, 0, 0, pool);
|
||||||
|
(void)res;
|
||||||
|
|
||||||
switch_sockaddr_info_get(&addr, host, SWITCH_UNSPEC, 0, 0, pool);
|
|
||||||
return switch_core_strdup(pool, switch_str_nil(switch_get_addr(buf, sizeof(buf), addr)));
|
return switch_core_strdup(pool, switch_str_nil(switch_get_addr(buf, sizeof(buf), addr)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -720,6 +723,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
|
||||||
int funny = 0;
|
int funny = 0;
|
||||||
int size = sizeof(buf);
|
int size = sizeof(buf);
|
||||||
int xlen = sizeof(switch_stun_packet_header_t);
|
int xlen = sizeof(switch_stun_packet_header_t);
|
||||||
|
switch_status_t res;
|
||||||
|
|
||||||
switch_assert(err);
|
switch_assert(err);
|
||||||
|
|
||||||
|
@ -729,25 +733,30 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
|
||||||
|
|
||||||
*err = "Success";
|
*err = "Success";
|
||||||
|
|
||||||
switch_sockaddr_info_get(&from_addr, NULL, SWITCH_UNSPEC, 0, 0, pool);
|
res = switch_sockaddr_info_get(&from_addr, NULL, SWITCH_UNSPEC, 0, 0, pool);
|
||||||
|
(void)res;
|
||||||
|
|
||||||
if (switch_sockaddr_info_get(&local_addr, *ip, SWITCH_UNSPEC, *port, 0, pool) != SWITCH_STATUS_SUCCESS) {
|
if (switch_sockaddr_info_get(&local_addr, *ip, SWITCH_UNSPEC, *port, 0, pool) != SWITCH_STATUS_SUCCESS) {
|
||||||
*err = "Local Address Error!";
|
*err = "Local Address Error!";
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_sockaddr_info_get(&remote_addr, stunip, SWITCH_UNSPEC, stunport, 0, pool) != SWITCH_STATUS_SUCCESS) {
|
if (switch_sockaddr_info_get(&remote_addr, stunip, SWITCH_UNSPEC, stunport, 0, pool) != SWITCH_STATUS_SUCCESS) {
|
||||||
*err = "Remote Address Error!";
|
*err = "Remote Address Error!";
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_socket_create(&sock, AF_INET, SOCK_DGRAM, 0, pool) != SWITCH_STATUS_SUCCESS) {
|
if (switch_socket_create(&sock, AF_INET, SOCK_DGRAM, 0, pool) != SWITCH_STATUS_SUCCESS) {
|
||||||
*err = "Socket Error!";
|
*err = "Socket Error!";
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_socket_bind(sock, local_addr) != SWITCH_STATUS_SUCCESS) {
|
if (switch_socket_bind(sock, local_addr) != SWITCH_STATUS_SUCCESS) {
|
||||||
*err = "Bind Error!";
|
*err = "Bind Error!";
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,7 +788,6 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
|
||||||
*ip = NULL;
|
*ip = NULL;
|
||||||
*port = 0;
|
*port = 0;
|
||||||
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
bytes = sizeof(buf);
|
bytes = sizeof(buf);
|
||||||
if (switch_socket_recvfrom(from_addr, sock, 0, (char *) &buf, &bytes) == SWITCH_STATUS_SUCCESS && bytes > 0) {
|
if (switch_socket_recvfrom(from_addr, sock, 0, (char *) &buf, &bytes) == SWITCH_STATUS_SUCCESS && bytes > 0) {
|
||||||
|
@ -790,10 +798,12 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
|
||||||
*err = "Timeout";
|
*err = "Timeout";
|
||||||
switch_socket_shutdown(sock, SWITCH_SHUTDOWN_READWRITE);
|
switch_socket_shutdown(sock, SWITCH_SHUTDOWN_READWRITE);
|
||||||
switch_socket_close(sock);
|
switch_socket_close(sock);
|
||||||
|
|
||||||
return SWITCH_STATUS_TIMEOUT;
|
return SWITCH_STATUS_TIMEOUT;
|
||||||
}
|
}
|
||||||
switch_cond_next();
|
switch_cond_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_socket_close(sock);
|
switch_socket_close(sock);
|
||||||
|
|
||||||
if (funny) {
|
if (funny) {
|
||||||
|
@ -803,14 +813,15 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
|
||||||
packet = switch_stun_packet_parse(start, size);
|
packet = switch_stun_packet_parse(start, size);
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
*err = "Invalid STUN/ICE packet";
|
*err = "Invalid STUN/ICE packet";
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf));
|
end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf));
|
||||||
|
|
||||||
switch_stun_packet_first_attribute(packet, attr);
|
switch_stun_packet_first_attribute(packet, attr);
|
||||||
switch_assert(attr);
|
switch_assert(attr);
|
||||||
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
switch (attr->type) {
|
switch (attr->type) {
|
||||||
case SWITCH_STUN_ATTR_MAPPED_ADDRESS:
|
case SWITCH_STUN_ATTR_MAPPED_ADDRESS:
|
||||||
|
@ -818,6 +829,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
|
||||||
switch_stun_ip_t *tmp = (switch_stun_ip_t *) attr->value;
|
switch_stun_ip_t *tmp = (switch_stun_ip_t *) attr->value;
|
||||||
tmp->address ^= ntohl(0xabcdabcd);
|
tmp->address ^= ntohl(0xabcdabcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_stun_packet_attribute_get_mapped_address(attr, rip, sizeof(rip), &rport);
|
switch_stun_packet_attribute_get_mapped_address(attr, rip, sizeof(rip), &rport);
|
||||||
break;
|
break;
|
||||||
case SWITCH_STUN_ATTR_XOR_MAPPED_ADDRESS:
|
case SWITCH_STUN_ATTR_XOR_MAPPED_ADDRESS:
|
||||||
|
@ -831,12 +843,15 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
|
||||||
if (!switch_stun_packet_next_attribute(attr, end_buf)) {
|
if (!switch_stun_packet_next_attribute(attr, end_buf)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
xlen += 4 + switch_stun_attribute_padded_length(attr);
|
xlen += 4 + switch_stun_attribute_padded_length(attr);
|
||||||
|
|
||||||
} while (xlen <= packet->header.length);
|
} while (xlen <= packet->header.length);
|
||||||
|
|
||||||
if (packet->header.type == SWITCH_STUN_BINDING_RESPONSE) {
|
if (packet->header.type == SWITCH_STUN_BINDING_RESPONSE) {
|
||||||
*ip = switch_core_strdup(pool, rip);
|
*ip = switch_core_strdup(pool, rip);
|
||||||
*port = rport;
|
*port = rport;
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
*err = "Invalid Reply";
|
*err = "Invalid Reply";
|
||||||
|
|
|
@ -1238,7 +1238,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
|
||||||
|
|
||||||
if (context->last_received_seq && context->last_received_seq + 1 != frame->seq) {
|
if (context->last_received_seq && context->last_received_seq + 1 != frame->seq) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, VPX_SWITCH_LOG_LEVEL, "Packet loss detected last=%d got=%d lost=%d\n", context->last_received_seq, frame->seq, frame->seq - context->last_received_seq);
|
switch_log_printf(SWITCH_CHANNEL_LOG, VPX_SWITCH_LOG_LEVEL, "Packet loss detected last=%d got=%d lost=%d\n", context->last_received_seq, frame->seq, frame->seq - context->last_received_seq);
|
||||||
if (is_keyframe && context->vpx_packet_buffer) switch_buffer_zero(context->vpx_packet_buffer);
|
if (is_keyframe) switch_buffer_zero(context->vpx_packet_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
context->last_received_seq = frame->seq;
|
context->last_received_seq = frame->seq;
|
||||||
|
|
|
@ -1726,6 +1726,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file)
|
||||||
if ( rename(new_file_tmp,new_file) ) {
|
if ( rename(new_file_tmp,new_file) ) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd = open(new_file, O_RDONLY, 0)) > -1) {
|
if ((fd = open(new_file, O_RDONLY, 0)) > -1) {
|
||||||
if ((xml = switch_xml_parse_fd(fd))) {
|
if ((xml = switch_xml_parse_fd(fd))) {
|
||||||
if (strcmp(abs, SWITCH_GLOBAL_filenames.conf_name)) {
|
if (strcmp(abs, SWITCH_GLOBAL_filenames.conf_name)) {
|
||||||
|
@ -1733,8 +1734,8 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file)
|
||||||
new_file = NULL;
|
new_file = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1747,10 +1748,6 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file)
|
||||||
write_fd = NULL;
|
write_fd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd > -1) {
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_safe_free(new_file_tmp);
|
switch_safe_free(new_file_tmp);
|
||||||
switch_safe_free(new_file);
|
switch_safe_free(new_file);
|
||||||
|
|
||||||
|
@ -2272,7 +2269,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
|
||||||
switch_event_destroy(&my_params);
|
switch_event_destroy(&my_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != SWITCH_STATUS_SUCCESS && root && *root) {
|
if (status != SWITCH_STATUS_SUCCESS && *root) {
|
||||||
switch_xml_free(*root);
|
switch_xml_free(*root);
|
||||||
*root = NULL;
|
*root = NULL;
|
||||||
*domain = NULL;
|
*domain = NULL;
|
||||||
|
|
Loading…
Reference in New Issue