Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udp: fix helpers mutex locking #1104

Closed
wants to merge 1 commit into from
Closed

Conversation

cspiel1
Copy link
Collaborator

@cspiel1 cspiel1 commented Apr 23, 2024

The current solution of protecting the helpers list against processing while there is a helper added/deleted is not sufficient.

Adding a helper most likely is save.

Deleting a helper makes the list element le invalid, further the UDP helper uh becomes invalid and may not be called.

@cspiel1
Copy link
Collaborator Author

cspiel1 commented Apr 23, 2024

Currently there is a deadlock in retest:

  • udp.c:199 the recvh of a helper calls indirectly
  • `udp_send_helper() and then tries to lock the mutex at udp.c:879

edit:
We discussed also a two mutex solution. One for receive and one for send. This also would lead to a deadlock, because
a normal use case is that a send helper may invoke udp_send_helper(), like it is done in baresip-s bundle.c. This again would lead to a deadlock if the lock is hold during udp_send_internal().

@cspiel1
Copy link
Collaborator Author

cspiel1 commented Apr 23, 2024

It's not possible to make helper_destructor() and processing of the helpers list thread safe. The upper layer has to ensure that no helper is freed while the stream is still active.

In this case it has to be solved in baresip/baresip#3012

@cspiel1 cspiel1 closed this Apr 23, 2024
@cspiel1 cspiel1 deleted the udp_helpers_lock branch April 23, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant