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

Handle 2nd INVITE when in early state #3458

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

ODCA117
Copy link
Contributor

@ODCA117 ODCA117 commented Mar 21, 2023

Ensures 2nd INVITE is handled if in state early.

@sauwming
Copy link
Member

As a reference, here's RFC 3261 section 14.2:

   A UAS that receives a second INVITE before it sends the final
   response to a first INVITE with a lower CSeq sequence number on the
   same dialog MUST return a 500 (Server Internal Error) response to the
   second INVITE and MUST include a Retry-After header field with a
   randomly chosen value of between 0 and 10 seconds.

   A UAS that receives an INVITE on a dialog while an INVITE it had sent
   on that dialog is in progress MUST return a 491 (Request Pending)
   response to the received INVITE.

pjsip/src/pjsip-ua/sip_inv.c Outdated Show resolved Hide resolved
pjsip/src/pjsip-ua/sip_inv.c Outdated Show resolved Hide resolved
pjsip/src/pjsip-ua/sip_inv.c Show resolved Hide resolved
@wosrediinanatour
Copy link
Contributor

Please use enum instead of magic numbers, e.g. 500 or 491.

@ODCA117 ODCA117 force-pushed the second_invite_response branch from 9c2031f to 9389560 Compare March 22, 2023 07:31
@ODCA117
Copy link
Contributor Author

ODCA117 commented Mar 22, 2023

Fixed the comments

@sauwming
Copy link
Member

Please find the attached patch below. Mostly, just to fix the indentation, but also one build failure of missing semicolon.

I have tested it here and it seems to work as expected.
sip_inv_early.txt

@ODCA117 ODCA117 force-pushed the second_invite_response branch from 9389560 to 60df91c Compare March 22, 2023 08:22
@sauwming sauwming changed the title 2nd INVITE not being handled Handle 2nd INVITE when in early state Mar 22, 2023
@sauwming sauwming added this to the release-2.14 milestone Mar 22, 2023
* between 0-10.
*/
pjsip_retry_after_hdr *ra_hdr;
int val = (pj_rand() % 9) + 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a similar handling in inv_on_state_confirmed(), and it use:

int val = (pj_rand() % 10);

Yes it is unclear whether between 0-10 should be inclusive, but I guess we better apply the same formula in early and confirmed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So changing back to int val = (pj_rand() % 10);?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like between in the RFC means inclusive such as any response with a status code between 100 and 199 is referred to as a "1xx response".

The correct one should be pj_rand() % 11. But I think % 10 is safer in case that there's any UA that rejects a value of 10.

So yes, please revert it to pj_rand() % 10. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Ensures 2nd INVITE is handled if in state early.
@ODCA117 ODCA117 force-pushed the second_invite_response branch from 60df91c to 9902c87 Compare March 28, 2023 11:10
@sauwming sauwming merged commit 340a1b2 into pjsip:master Mar 30, 2023
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.

4 participants