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

Add onreply_route async capabilities #3550

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vladpaiu
Copy link
Member

@vladpaiu vladpaiu commented Jan 3, 2025

Summary
Add onreply_route async capabilities

Solution
Clone reply before running async functions & free afterwards

Compatibility
Backwards incompatible, previous async in onreply_route was run in sync mode.

@vladpaiu vladpaiu added this to the 3.6-dev milestone Jan 3, 2025
@vladpaiu vladpaiu requested a review from bogdan-iancu January 3, 2025 13:49
@bogdan-iancu
Copy link
Member

@vladpaiu , this sounds awesome !!! Let me check it !

if (async_status > 0) {
/* async was started in the onreply route, no need to do anything more here */
/* mark that the UAC received replies */
uac->flags |= T_UAC_HAS_RECV_REPLY;
Copy link
Member

Choose a reason for hiding this comment

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

does it make any difference if we move the setting of the flag before running the onreply route, so we do not have to duplicate ?

@@ -319,8 +553,18 @@ int t_handle_async(struct sip_msg *msg, struct action* a,
}

if (route_type!=REQUEST_ROUTE) {
Copy link
Member

Choose a reason for hiding this comment

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

Some

if ()
else if ()
else

may look better here :)

/* DO TM suspended actions to decide if we need to relay */
LOCK_REPLIES( t );

/* we fire a cancel on spot if (a) branch is marked "to be canceled" or (b)
Copy link
Member

Choose a reason for hiding this comment

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

this chunk below is duplicated from the reply_received() (all the way to restore_exit_reply label). I haven;t looked into details, but maybe we should avoid code duplicate, especially in such a delicate section, on reply handing. Maybe some refactoring into some new inline function ?

/* run the resume_route (some type as the original one) */
swap_route_type(route, ctx->route_type);
/* do not run any post script callback, we are a reply */
run_resume_route( ctx->resume_route, ctx->reply, 0);
Copy link
Member

Choose a reason for hiding this comment

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

The initial onreply route allows you to run with the lock (see the onreply_avp_mode setting) or without lock. The resume route is not impacted (correct me if I'm wrong) by this setting, leading to concurrent access to the transactional list of AVPS.

set_cancelled_t(ctx->cancelled_t);
set_e2eack_t(ctx->e2eack_t);
reset_kr();
set_kr(ctx->kr);
Copy link
Member

Choose a reason for hiding this comment

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

I do not see this ctx->kr set anywhere (in the new code). Do we need this? KR is typical for request processing, not for replies.
Similar the e2eack and cancel stuff.

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.

2 participants