Skip to content

Commit

Permalink
udp: lock list_unlink of udp helper
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Mar 10, 2023
1 parent 5ea7dce commit 5d78103
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/udp/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct udp_sock {
QOS_FLOWID qos_id; /**< QOS IPv4 flow id */
QOS_FLOWID qos_id6; /**< QOS IPv6 flow id */
#endif
mtx_t *lock; /**< A lock for helpers */
mtx_t *lock; /**< A lock for helpers list */
};

/** Defines a UDP helper */
Expand All @@ -84,6 +84,7 @@ struct udp_helper {
int layer;
udp_helper_send_h *sendh;
udp_helper_recv_h *recvh;
mtx_t *lock; /**< A lock for helpers list */
void *arg;
};

Expand Down Expand Up @@ -873,7 +874,9 @@ static void helper_destructor(void *data)
{
struct udp_helper *uh = data;

mtx_lock(uh->lock);
list_unlink(&uh->le);
mtx_unlock(uh->lock);
}


Expand Down Expand Up @@ -915,6 +918,7 @@ int udp_register_helper(struct udp_helper **uhp, struct udp_sock *us,
mtx_lock(us->lock);
list_append(&us->helpers, &uh->le, uh);

uh->lock = us->lock;
uh->layer = layer;
uh->sendh = sh ? sh : helper_send_handler;
uh->recvh = rh ? rh : helper_recv_handler;
Expand Down

0 comments on commit 5d78103

Please sign in to comment.