Skip to content

Commit

Permalink
udp: do not lock rh in udp_recv_packet; simplify lock in udp_helper_find
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Mar 9, 2023
1 parent 86d1e1d commit 5ea7dce
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/udp/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,6 @@ void udp_recv_helper(struct udp_sock *us, const struct sa *src,
struct udp_helper *udp_helper_find(const struct udp_sock *us, int layer)
{
struct le *le;
struct udp_helper *uhf = NULL;

if (!us)
return NULL;
Expand All @@ -1003,13 +1002,13 @@ struct udp_helper *udp_helper_find(const struct udp_sock *us, int layer)
struct udp_helper *uh = le->data;

if (layer == uh->layer) {
uhf = uh;
break;
mtx_unlock(us->lock);
return uh;
}
}

mtx_unlock(us->lock);
return uhf;
return NULL;
}


Expand Down Expand Up @@ -1064,11 +1063,12 @@ void udp_recv_packet(struct udp_sock *us, const struct sa *src,
}

hdld = uh->recvh(&hsrc, mb, uh->arg);
if (hdld)
goto out;
if (hdld) {
mtx_unlock(us->lock);
return;
}
}

us->rh(src, mb, us->arg);
out:
mtx_unlock(us->lock);
us->rh(src, mb, us->arg);
}

0 comments on commit 5ea7dce

Please sign in to comment.