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

Prevent race condition within DNS callbacks in pjsip resolver #3991

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

sauwming
Copy link
Member

In our DNS resolver, in order to avoid deadlock, we utilize a workaround in #1108 by releasing the lock before calling the callback.

However, this means that there can be a race condition. In sip_resolve, it is reported that the callback can be called twice when DNS A and AAAA responses are processed at the same time:

06-15 01:36:26.024   597   597 D SipTelecomPJ: 01:36:26.024     resolver.c  ...Transmitting 32 bytes to NS 0 ([...:53](http://...:53/)): DNS A query for [domain.net](http://domain.net/): Success
06-15 01:36:26.026   597   923 D SipTelecomPJ: 01:36:26.026   pjsua_core.c  TX 745 bytes Request msg SUBSCRIBE/cseq=1832 (tdta0x9061e068) to TLS [...:5061](http://...:5061/):
06-15 01:36:26.026   597   923 D SipTelecomPJ: SUBSCRIBE  ...
...

06-15 01:36:26.027   597   597 D SipTelecomPJ: 01:36:26.024  sip_resolve.c  ...DNS AAAA record resolution failed: No answer record in the DNS response (PJLIB_UTIL_EDNSNOANSWERREC)
06-15 01:36:26.027   597   597 D SipTelecomPJ: 01:36:26.027   pjsua_core.c !...TX 745 bytes Request msg SUBSCRIBE/cseq=1832 (tdta0x9061e068) to TLS [...:5061](http://...:5061/):
06-15 01:36:26.027   597   597 D SipTelecomPJ: SUBSCRIBE ...
...
06-15 01:36:26.028   597   597 D SipTelecomPJ: 01:36:26.028 evsub0x9060c86  .....Subscription state changed NULL --> SENT cause

@sauwming sauwming merged commit cd89bb6 into master Jun 19, 2024
36 checks passed
@sauwming sauwming deleted the sip-resolve-lock branch June 19, 2024 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants