-
Notifications
You must be signed in to change notification settings - Fork 452
MT#55283 add rollback NG message #2159
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4c7b277
MT#55283 add rollback NG message
danieldonoghue ad49459
MT#55283 address review comments
danieldonoghue ff47944
MT#55283 scope snapshots to the dialogue
danieldonoghue 3bb19f2
MT#55283 give each monologue its own checkpoint
danieldonoghue 0c986a8
MT#55283 do not report a rollback that did not happen
danieldonoghue dfe7a72
MT#55283 document that merging a call drops its checkpoints
danieldonoghue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -652,10 +652,18 @@ static const char *call_offer_answer_ng(ng_command_ctx_t *ctx, const char *addr) | |
| t_hash_table_insert(call->endpoints, memory_arena_objdup(streams.head->data->rtp_endpoint), | ||
| from_ml); | ||
|
|
||
| if (flags.opmode == OP_OFFER) { | ||
| // opened before SDP processing, to capture the pre-offer state. left | ||
| // pending if the offer is rejected: it's still the committed state | ||
| call_checkpoint_offer(call, from_ml, to_ml, flags.track_state); | ||
| } | ||
|
|
||
| struct recording *recording = NULL; | ||
|
|
||
| /* offer/answer model processing */ | ||
| if ((ret = monologue_offer_answer(monologues, &streams, &flags)) == 0) { | ||
| if (flags.opmode == OP_ANSWER) | ||
| call_checkpoint_answer(call, from_ml, to_ml); | ||
| update_metadata_monologue(from_ml, &flags); | ||
| detect_setup_recording(call, &flags); | ||
|
|
||
|
|
@@ -681,6 +689,10 @@ static const char *call_offer_answer_ng(ng_command_ctx_t *ctx, const char *addr) | |
| /* place return output SDP */ | ||
| ctx->ngbuf->sdp_out = sdp_out.s; | ||
| ctx->parser_ctx.parser->dict_add_str(output, "sdp", &sdp_out); | ||
| if (flags.supports_rollback) { | ||
| parser_arg supported = parser->dict_add_list(output, "supported"); | ||
| parser->list_add_string(supported, "rollback"); | ||
| } | ||
|
|
||
| meta_write_sdp_after(recording, &sdp_out, from_ml, flags.opmode); | ||
|
|
||
|
|
@@ -734,6 +746,59 @@ const char *call_answer_ng(ng_command_ctx_t *ctx) { | |
| return call_offer_answer_ng(ctx, NULL); | ||
| } | ||
|
|
||
| static bool monologue_has_tag(const struct call_monologue *ml, const str *tag) { | ||
| if (!str_cmp_str(&ml->tag, tag)) | ||
| return true; | ||
| for (__auto_type l = ml->tag_aliases.head; l; l = l->next) { | ||
| if (!str_cmp_str(l->data, tag)) | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| const char *call_rollback_ng(ng_command_ctx_t *ctx) { | ||
| const ng_parser_t *parser = ctx->parser_ctx.parser; | ||
| str call_id = parser->dict_get_str(ctx->req, "call-id"); | ||
| str from_tag = parser->dict_get_str(ctx->req, "from-tag"); | ||
| str to_tag = parser->dict_get_str(ctx->req, "to-tag"); | ||
| str via_branch = parser->dict_get_str(ctx->req, "via-branch"); | ||
|
|
||
| if (!call_id.len) | ||
| return "No call-id in message"; | ||
| if (!from_tag.len) | ||
| return "No from-tag in message"; | ||
| if (!to_tag.len) | ||
| return "No to-tag in message"; | ||
|
|
||
| call_t *call = call_get(&call_id); | ||
| if (!call) | ||
| return "Unknown call-id"; | ||
|
|
||
| struct call_monologue *from_ml = call_get_monologue(call, &from_tag); | ||
| struct call_monologue *to_ml = via_branch.len | ||
| ? t_hash_table_lookup(call->viabranches, &via_branch) | ||
| : call_get_monologue(call, &to_tag); | ||
| // call_get_monologue() is keyed on the tag, so from_ml carries it by | ||
| // construction. to_ml may have come from the viabranch table instead. | ||
| if (!from_ml || !to_ml || from_ml == to_ml | ||
| || !monologue_has_tag(to_ml, &to_tag) | ||
| || !g_hash_table_contains(from_ml->associated_tags, to_ml)) | ||
| { | ||
|
Comment on lines
+777
to
+786
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still feel like there should be an existing function which already does this sufficiently, without having to double check the returned objects. |
||
| rwlock_unlock_w(&call->master_lock); | ||
| obj_put(call); | ||
| return "Unknown dialogue"; | ||
| } | ||
| if (rtpe_config.active_switchover && IS_FOREIGN_CALL(call)) | ||
| call_make_own_foreign(call, false); | ||
|
|
||
| int rolled_back = call_checkpoint_rollback(call, from_ml, to_ml); | ||
| parser->dict_add_int(ctx->resp, "rolled-back", rolled_back); | ||
| rwlock_unlock_w(&call->master_lock); | ||
| redis_update_onekey(call, rtpe_redis_write); | ||
| obj_put(call); | ||
| return NULL; | ||
| } | ||
|
|
||
| const char *call_delete_ng(ng_command_ctx_t *ctx) { | ||
| g_auto(sdp_ng_flags) rtpp_flags; | ||
| parser_arg output = ctx->resp; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked, but I think all instances of this being used already have some sort of loop over the respective monologues, so the freeing of the snapshots could be rolled into those. But also a minor point that could be left for later.