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

Not disposing registration timer in SIPRegistrationUserAgent on unequivocal failure #1163

Closed
mikhail-barg opened this issue Aug 16, 2024 · 2 comments · Fixed by #1205
Closed

Comments

@mikhail-barg
Copy link

Hi, we just stumbled on a problem with SIPRegistrationUserAgent when exitOnUnequivocalFailure is set to true, which is default.

So when a failure happens, the m_exit variable is set to m_exitOnUnequivocalFailure (which is true):

else if (sipResponse.Status == SIPResponseStatusCodesEnum.Forbidden || sipResponse.Status == SIPResponseStatusCodesEnum.NotFound)
{
// SIP account does not appear to exist.
m_exit = m_exitOnUnequivocalFailure;
logger.LogWarning($"Registration unequivocal failure with {sipResponse.Status} for {m_sipAccountAOR}{(m_exit ? ", no further registration attempts will be made" : "")}.");

(and two other similar places).

But then during the Stop() call, m_exit is being checked, and no call to m_registrationTimer.Dispose() happens:

public void Stop(bool sendZeroExpiryRegister = true)
{
try
{
if (!m_exit)
{
logger.LogDebug($"Stopping SIP registration user agent for {m_sipAccountAOR}.");
m_exit = true;
m_waitForRegistrationMRE.Set();
if (m_isRegistered && sendZeroExpiryRegister)
{
m_attempts = 0;
m_expiry = 0;
ThreadPool.QueueUserWorkItem(delegate { SendInitialRegister(); });
}
m_registrationTimer.Dispose();
m_registrationTimer = null;
}
}
catch (Exception excp)

And this is the only place where the timer is being disposed.

This causes an infinite re-registration loop for the account which is already not being used, and other nasty consequences.

@sipsorcery
Copy link
Member

Thanks for logging the bug. I've created a PR to fix in #1205.

@mikhail-barg
Copy link
Author

Thanks for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants