Browse Source

MT#55283 use auto lock in a few more places

Change-Id: Ibf34fa6e8cdcbf122e548475ba086101a6757a66
pull/1980/head
Richard Fuchs 5 months ago
parent
commit
1b077c300a
2 changed files with 13 additions and 25 deletions
  1. +3
    -5
      daemon/call.c
  2. +10
    -20
      daemon/media_socket.c

+ 3
- 5
daemon/call.c View File

@ -185,7 +185,8 @@ static void call_timer_iterator(call_t *c, struct iterator_helper *hlp) {
timestamp = packet_stream_last_packet(ps);
if (!ps->media)
goto next;
continue;
sfd = ps->selected_sfd;
if (!sfd)
goto no_sfd;
@ -215,7 +216,7 @@ static void call_timer_iterator(call_t *c, struct iterator_helper *hlp) {
no_sfd:
if (good)
goto next;
continue;
check = atomic_get_na(&rtpe_config.timeout_us);
tmp_t_reason = TIMEOUT;
@ -230,9 +231,6 @@ no_sfd:
if (timestamp > rtpe_now || rtpe_now - timestamp < check)
good = true;
next:
;
}
for (__auto_type it = c->medias.head; it; it = it->next) {


+ 10
- 20
daemon/media_socket.c View File

@ -2190,7 +2190,7 @@ static int media_demux_protocols(struct packet_handler_ctx *phc) {
#if RTP_LOOP_PROTECT
// returns: 0 = ok, proceed; -1 = duplicate detected, drop packet
static int media_loop_detect(struct packet_handler_ctx *phc) {
mutex_lock(&phc->mp.stream->in_lock);
LOCK(&phc->mp.stream->in_lock);
for (int i = 0; i < RTP_LOOP_PACKETS; i++) {
if (phc->mp.stream->lp_buf[i].len != phc->s.len)
@ -2204,12 +2204,11 @@ static int media_loop_detect(struct packet_handler_ctx *phc) {
"to avoid potential loop",
RTP_LOOP_MAX_COUNT,
FMT_M(endpoint_print_buf(&phc->mp.fsin)));
mutex_unlock(&phc->mp.stream->in_lock);
return -1;
}
phc->mp.stream->lp_count++;
goto loop_ok;
return 0;
}
/* not a dupe */
@ -2217,8 +2216,6 @@ static int media_loop_detect(struct packet_handler_ctx *phc) {
phc->mp.stream->lp_buf[phc->mp.stream->lp_idx].len = phc->s.len;
memcpy(phc->mp.stream->lp_buf[phc->mp.stream->lp_idx].buf, phc->s.s, MIN(phc->s.len, RTP_LOOP_PROTECT));
phc->mp.stream->lp_idx = (phc->mp.stream->lp_idx + 1) % RTP_LOOP_PACKETS;
loop_ok:
mutex_unlock(&phc->mp.stream->in_lock);
return 0;
}
@ -2331,7 +2328,7 @@ static void media_packet_rtp_out(struct packet_handler_ctx *phc, struct sink_han
static int media_packet_decrypt(struct packet_handler_ctx *phc)
{
mutex_lock(&phc->in_srtp->in_lock);
LOCK(&phc->in_srtp->in_lock);
struct sink_handler *first_sh = phc->sinks->length ? phc->sinks->head->data : NULL;
const struct streamhandler *sh = __determine_handler(phc->in_srtp, first_sh);
@ -2352,8 +2349,6 @@ static int media_packet_decrypt(struct packet_handler_ctx *phc)
phc->mp.payload.len -= ori_s.len - phc->s.len;
}
mutex_unlock(&phc->in_srtp->in_lock);
if (ret == 1) {
phc->update = true;
ret = 0;
@ -2362,7 +2357,7 @@ static int media_packet_decrypt(struct packet_handler_ctx *phc)
}
static void media_packet_set_encrypt(struct packet_handler_ctx *phc, struct sink_handler *sh)
{
mutex_lock(&phc->in_srtp->in_lock);
LOCK(&phc->in_srtp->in_lock);
__determine_handler(phc->in_srtp, sh);
// XXX use an array with index instead of if/else
@ -2372,7 +2367,6 @@ static void media_packet_set_encrypt(struct packet_handler_ctx *phc, struct sink
phc->encrypt_func = sh->handler->out->rtcp_crypt;
phc->rtcp_filter = sh->handler->in->rtcp_filter;
}
mutex_unlock(&phc->in_srtp->in_lock);
}
int media_packet_encrypt(rewrite_func encrypt_func, struct packet_stream *out, struct media_packet *mp) {
@ -2417,7 +2411,7 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc)
{
bool ret = false;
mutex_lock(&phc->mp.stream->in_lock);
LOCK(&phc->mp.stream->in_lock);
/* we're OK to (potentially) use the source address of this packet as destination
* in the other direction. */
@ -2425,11 +2419,11 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc)
if (!PS_ISSET(phc->mp.stream, FILLED)) {
__C_DBG("stream %s:%d not FILLED", sockaddr_print_buf(&phc->mp.stream->endpoint.address),
phc->mp.stream->endpoint.port);
goto out;
return false;
}
if (!MEDIA_ISSET(phc->mp.media, PUBLIC)) {
__C_DBG("media not answered");
goto out;
return false;
}
// GH #697 - apparent Asterisk bug where it sends stray RTCP to the RTP port.
@ -2441,7 +2435,7 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc)
ilog(LOG_DEBUG | LOG_FLAG_LIMIT, "Ignoring stray RTCP packet from %s%s%s for "
"peer address confirmation purposes",
FMT_M(endpoint_print_buf(&phc->mp.fsin)));
goto out;
return false;
}
}
@ -2496,7 +2490,7 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc)
}
}
phc->kernelize = true;
goto out;
return ret;
}
/* wait at least 3 seconds after last signal before committing to a particular
@ -2553,8 +2547,7 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc)
FMT_M(endpoint_print_buf(use_endpoint_confirm)));
atomic64_inc_na(&phc->mp.stream->stats_in->errors);
atomic64_inc_na(&phc->mp.sfd->local_intf->stats->in.errors);
ret = true;
goto out;
return true;
}
}
@ -2613,9 +2606,6 @@ update_addr:
}
}
out:
mutex_unlock(&phc->mp.stream->in_lock);
return ret;
}


Loading…
Cancel
Save