Miscelaneous Coverity fixes (#3792)
* Fix CID: 1527652, 1524421, 1524414, 1524392 * Fixed UPnP data races
This commit is contained in:
parent
b981b45183
commit
8e9857a81e
|
@ -1049,6 +1049,7 @@ PJ_DEF(pj_status_t) pjmedia_conf_disconnect_port( pjmedia_conf *conf,
|
|||
unsigned sink_slot )
|
||||
{
|
||||
struct conf_port *src_port, *dst_port;
|
||||
pj_bool_t no_conn = PJ_FALSE;
|
||||
unsigned i;
|
||||
|
||||
/* Check arguments */
|
||||
|
@ -1098,9 +1099,12 @@ PJ_DEF(pj_status_t) pjmedia_conf_disconnect_port( pjmedia_conf *conf,
|
|||
pjmedia_delay_buf_reset(src_port->delay_buf);
|
||||
}
|
||||
|
||||
/* Evaluate connect_cnt with mutex, but pause sound dev outside mutex */
|
||||
no_conn = (conf->connect_cnt == 0);
|
||||
|
||||
pj_mutex_unlock(conf->mutex);
|
||||
|
||||
if (conf->connect_cnt == 0) {
|
||||
if (no_conn) {
|
||||
pause_sound(conf);
|
||||
}
|
||||
|
||||
|
|
|
@ -325,12 +325,14 @@ static void add_device(const char *dev_id, const char *url)
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
pj_mutex_lock(upnp_mgr.mutex);
|
||||
|
||||
if (upnp_mgr.igd_cnt >= MAX_DEVS) {
|
||||
pj_mutex_unlock(upnp_mgr.mutex);
|
||||
PJ_LOG(3, (THIS_FILE, "Warning: Too many UPnP devices discovered"));
|
||||
return;
|
||||
}
|
||||
|
||||
pj_mutex_lock(upnp_mgr.mutex);
|
||||
for (i = 0; i < upnp_mgr.igd_cnt; i++) {
|
||||
if (!pj_strcmp2(&upnp_mgr.igd_devs[i].dev_id, dev_id) &&
|
||||
!pj_strcmp2(&upnp_mgr.igd_devs[i].url, url))
|
||||
|
@ -358,6 +360,8 @@ static void set_device_online(const char *dev_id)
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
pj_mutex_lock(upnp_mgr.mutex);
|
||||
|
||||
for (i = 0; i < upnp_mgr.igd_cnt; i++) {
|
||||
struct igd *igd = &upnp_mgr.igd_devs[i];
|
||||
|
||||
|
@ -367,15 +371,15 @@ static void set_device_online(const char *dev_id)
|
|||
|
||||
if (upnp_mgr.primary_igd_idx < 0) {
|
||||
/* If we don't have a primary IGD, use this. */
|
||||
pj_mutex_lock(upnp_mgr.mutex);
|
||||
upnp_mgr.primary_igd_idx = i;
|
||||
pj_mutex_unlock(upnp_mgr.mutex);
|
||||
|
||||
PJ_LOG(4, (THIS_FILE, "Using primary IGD %s",
|
||||
upnp_mgr.igd_devs[i].dev_id.ptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pj_mutex_unlock(upnp_mgr.mutex);
|
||||
}
|
||||
|
||||
/* Update IGD status to offline. */
|
||||
|
|
|
@ -1111,8 +1111,10 @@ void on_ip_change_progress(pjsua_ip_change_op op,
|
|||
case PJSUA_IP_CHANGE_OP_COMPLETED:
|
||||
pj_ansi_snprintf(info_str, sizeof(info_str),
|
||||
"done");
|
||||
break;
|
||||
default:
|
||||
info_str[0] = '\0';
|
||||
pj_ansi_snprintf(info_str, sizeof(info_str),
|
||||
"unknown-op");
|
||||
break;
|
||||
}
|
||||
PJ_LOG(3,(THIS_FILE, "IP change progress report : %s", info_str));
|
||||
|
|
|
@ -777,7 +777,6 @@ PJ_DEF(pj_status_t) pjsip_publishc_send(pjsip_publishc *pubc,
|
|||
return PJ_EBUSY;
|
||||
}
|
||||
}
|
||||
pj_mutex_unlock(pubc->mutex);
|
||||
|
||||
/* If via_addr is set, use this address for the Via header. */
|
||||
if (pubc->via_addr.host.slen > 0) {
|
||||
|
@ -798,6 +797,9 @@ PJ_DEF(pj_status_t) pjsip_publishc_send(pjsip_publishc *pubc,
|
|||
* may be called even before send_request() returns!
|
||||
*/
|
||||
++pubc->pending_tsx;
|
||||
|
||||
pj_mutex_unlock(pubc->mutex);
|
||||
|
||||
status = pjsip_endpt_send_request(pubc->endpt, tdata, -1, pubc,
|
||||
&tsx_callback);
|
||||
if (status!=PJ_SUCCESS) {
|
||||
|
|
|
@ -880,6 +880,7 @@ pjsip_tsx_detect_merged_requests(pjsip_rx_data *rdata)
|
|||
{
|
||||
pj_str_t key, key2;
|
||||
pj_uint32_t hval = 0;
|
||||
pjsip_transaction *tsx = NULL;
|
||||
pj_status_t status;
|
||||
|
||||
PJ_ASSERT_RETURN(rdata->msg_info.msg->type == PJSIP_REQUEST_MSG, NULL);
|
||||
|
@ -895,12 +896,15 @@ pjsip_tsx_detect_merged_requests(pjsip_rx_data *rdata)
|
|||
if (status != PJ_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
pj_mutex_lock( mod_tsx_layer.mutex );
|
||||
|
||||
/* This request must not match any transaction in our primary hash
|
||||
* table.
|
||||
*/
|
||||
if (pj_hash_get_lower(mod_tsx_layer.htable, key.ptr, (unsigned)key.slen,
|
||||
&hval) != NULL)
|
||||
{
|
||||
pj_mutex_unlock( mod_tsx_layer.mutex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -910,14 +914,18 @@ pjsip_tsx_detect_merged_requests(pjsip_rx_data *rdata)
|
|||
status = create_tsx_key_2543(rdata->tp_info.pool, &key2, PJSIP_ROLE_UAS,
|
||||
&rdata->msg_info.cseq->method, rdata,
|
||||
PJ_FALSE);
|
||||
if (status != PJ_SUCCESS)
|
||||
if (status != PJ_SUCCESS) {
|
||||
pj_mutex_unlock( mod_tsx_layer.mutex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hval = 0;
|
||||
return (pjsip_transaction *) pj_hash_get_lower(mod_tsx_layer.htable2,
|
||||
key2.ptr,
|
||||
(unsigned)key2.slen,
|
||||
&hval);
|
||||
tsx = pj_hash_get_lower(mod_tsx_layer.htable2, key2.ptr,
|
||||
(unsigned)key2.slen, &hval);
|
||||
|
||||
pj_mutex_unlock( mod_tsx_layer.mutex);
|
||||
|
||||
return tsx;
|
||||
}
|
||||
|
||||
/* This module callback is called when endpoint has received an
|
||||
|
|
Loading…
Reference in New Issue