[Asterisk-code-review] res ari: Add "module loaded" check to ari stubs (asterisk[13])
Richard Mudgett
asteriskteam at digium.com
Tue Jun 13 13:33:27 CDT 2017
Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/5809 )
Change subject: res_ari: Add "module loaded" check to ari stubs
......................................................................
Patch Set 2: Code-Review-1
(1 comment)
https://gerrit.asterisk.org/#/c/5809/2/rest-api-templates/res_ari_resource.c.mustache
File rest-api-templates/res_ari_resource.c.mustache:
https://gerrit.asterisk.org/#/c/5809/2/rest-api-templates/res_ari_resource.c.mustache@265
PS2, Line 265: {{#apis}}
: {{#operations}}
: {{#has_websocket}}
: struct ast_websocket_protocol *protocol;
:
: {{full_name}}.ws_server = ast_websocket_server_create();
: if (!{{full_name}}.ws_server) {
: return AST_MODULE_LOAD_DECLINE;
: }
:
: protocol = ast_websocket_sub_protocol_alloc("{{websocket_protocol}}");
: if (!protocol) {
: ao2_ref({{full_name}}.ws_server, -1);
: {{full_name}}.ws_server = NULL;
: return AST_MODULE_LOAD_DECLINE;
: }
: protocol->session_attempted = ast_ari_{{c_name}}_{{c_nickname}}_ws_attempted_cb;
: protocol->session_established = ast_ari_{{c_name}}_{{c_nickname}}_ws_established_cb;
: {{/has_websocket}}
: {{#is_websocket}}
: res |= ast_websocket_server_add_protocol2({{full_name}}.ws_server, protocol);
: {{/is_websocket}}
: {{/operations}}
: {{/apis}}
:
: CHECK_ARI_MODULE_LOADED();
{full_name}.ws_server
is leaked if CHECK_ARI_MODULE_LOADED() declines the load.
To fix probably have to move CHECK_ARI_MODULE_LOADED() to right after res is declared. Since protocol is declared after that, some blocking curly braces are needed inside the #operations block so we don't violate the variables must be declared at the start of a block requirement:
int res = 0;
CHECK_ARI_MODULE_LOADED();
{{#apis}}
{{#operations}}
{
... surrounded code indented by another level.
}
{{/operations}}
{{/apis}}
--
To view, visit https://gerrit.asterisk.org/5809
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: comment
Gerrit-Change-Id: I263d56efa628ee3c411bdcd16d49af6260c6c91d
Gerrit-Change-Number: 5809
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Tue, 13 Jun 2017 18:33:27 +0000
Gerrit-HasComments: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170613/ebb18f29/attachment.html>
More information about the asterisk-code-review
mailing list