[Asterisk-code-review] ARI channels: exposed channel driver's unique id (which is the Call-I... (asterisk[master])

Moritz Fain asteriskteam at digium.com
Wed Apr 27 06:56:22 CDT 2022


Attention is currently required from: Kevin Harwell, Richard Mudgett.
Moritz Fain has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/18413 )

Change subject: ARI channels: exposed channel driver's unique id (which is the Call-ID for SIP/PJSIP) to ARI channel resource as 'pvt_id'
......................................................................


Patch Set 6:

(5 comments)

File channels/chan_pjsip.c:

https://gerrit.asterisk.org/c/asterisk/+/18413/comment/7f2c481e_f1baff4c 
PS6, Line 575: 	ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
> I wonder if this should moved into the ast_channel_tech_pvt_set call itself. […]
I first put "ast_channel_snapshot_invalidate_segment" at the bottom of "begin_dial_prerun" (in dial.c) so that all channel drivers would benefit from the change. But that would only work for outgoing calls, not for incoming calls.

Also found it tempting to put it in ast_channel_tech_pvt_set, but didn't know if it was a good idea. After a quick look through the code I would say it wouldn't hurt... But I would only want to invalidate the BASE segment if the value is not reset (set to NULL) so that pvt_id isn't missing in Channel down/hangup events as ast_channel_tech_pvt_set is already being resetted by that time.

```
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
{
	chan->tech_pvt = value;
	if (value != NULL) {
		ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
	}
}
```

On the other hand: chan_sip and chan_pjsip are the only channel drivers which are specifying a "get_pvt_uniqueid" function and would need the invalidation.


https://gerrit.asterisk.org/c/asterisk/+/18413/comment/961f0bf9_1bd5fdfc 
PS6, Line 1277: 	if (!channel || !uniqueid) {
> Is it possible for channel to be NULL here?
Yes, chan_pjsip_new is calling ast_channel_alloc_with_endpoint which is calling channel_snapshot_base_create where I need to access ->get_pvt_uniqueid(chan).

But ast_channel_tech_pvt_set is only called *after* ast_channel_alloc_with_endpoint.

chan_sip's unique id function basically does the same check.


File include/asterisk/stasis_channels.h:

https://gerrit.asterisk.org/c/asterisk/+/18413/comment/e6d33224_ab04023e 
PS6, Line 108: 		AST_STRING_FIELD(pvt_uniqueid);  /*!< Channel drivers unique id */
> Extended string fields are only necessary on released branches to avoid ABI breakage.
Right.

It looks like I'm the first one using AST_STRING_FIELD_EXTENDED now :)


File main/stasis_channels.c:

https://gerrit.asterisk.org/c/asterisk/+/18413/comment/34f1505f_2c2a6ff2 
PS6, Line 287: 		ast_string_field_set(snapshot, pvt_uniqueid, ast_strdupa(ast_channel_tech(chan)->get_pvt_uniqueid(chan)));
> When you use the extended declaration you'll also need to initialize this a bit differently. […]
Ack


https://gerrit.asterisk.org/c/asterisk/+/18413/comment/283c6406_ed4e0fdb 
PS6, Line 289: 		ast_string_field_set(snapshot, pvt_uniqueid, ast_channel_uniqueid(chan));
> I'm torn having it default to the channel's 'uniqueid'. […]
Yes, changing it to empty.



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18413
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I7cc6e7a9d29efe74bc27811d788dac20fe559b87
Gerrit-Change-Number: 18413
Gerrit-PatchSet: 6
Gerrit-Owner: Moritz Fain <moritz at fain.io>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-CC: Richard Mudgett <rmudgett at digium.com>
Gerrit-Attention: Kevin Harwell <kharwell at digium.com>
Gerrit-Attention: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Wed, 27 Apr 2022 11:56:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Kevin Harwell <kharwell at digium.com>
Comment-In-Reply-To: Richard Mudgett <rmudgett at digium.com>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220427/2852494f/attachment.html>


More information about the asterisk-code-review mailing list