[Asterisk-code-review] res_ari_events: Add module reference when a WebSocket is open. (...asterisk[master])

Joshua Colp asteriskteam at digium.com
Tue Oct 29 10:25:08 CDT 2019


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/13106 )

Change subject: res_ari_events: Add module reference when a WebSocket is open.
......................................................................

res_ari_events: Add module reference when a WebSocket is open.

This change ensures that the module isn't unloaded when a
WebSocket is open. Previously it was possible to unload the
module manually or during shutdown which could cause a crash
when any active WebSockets were terminated.

ASTERISK-28585

Change-Id: I85c71ab112f99875b586419a34c08c8b34c14c5c
---
M res/res_ari_events.c
M rest-api-templates/res_ari_resource.c.mustache
2 files changed, 4 insertions(+), 0 deletions(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit



diff --git a/res/res_ari_events.c b/res/res_ari_events.c
index c8f28f9..1c4655f 100644
--- a/res/res_ari_events.c
+++ b/res/res_ari_events.c
@@ -150,6 +150,8 @@
 	RAII_VAR(struct ast_websocket *, s, ws_session, ast_websocket_unref);
 	RAII_VAR(struct ast_ari_websocket_session *, session, NULL, ao2_cleanup);
 
+	SCOPED_MODULE_USE(ast_module_info->self);
+
 	response = ast_calloc(1, sizeof(*response));
 	if (!response) {
 		ast_log(LOG_ERROR, "Failed to create response.\n");
diff --git a/rest-api-templates/res_ari_resource.c.mustache b/rest-api-templates/res_ari_resource.c.mustache
index 85948fb..e320f19 100644
--- a/rest-api-templates/res_ari_resource.c.mustache
+++ b/rest-api-templates/res_ari_resource.c.mustache
@@ -211,6 +211,8 @@
 	struct ast_variable *path_vars = NULL;
 {{/has_path_parameters}}
 
+	SCOPED_MODULE_USE(ast_module_info->self);
+
 {{#has_parameters}}
 	response = ast_calloc(1, sizeof(*response));
 	if (!response) {

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I85c71ab112f99875b586419a34c08c8b34c14c5c
Gerrit-Change-Number: 13106
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191029/79bc7d09/attachment-0001.html>


More information about the asterisk-code-review mailing list