]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_ari_events: Add module reference when a WebSocket is open.
authorJoshua Colp <jcolp@digium.com>
Thu, 24 Oct 2019 10:21:31 +0000 (07:21 -0300)
committerJoshua Colp <jcolp@digium.com>
Thu, 24 Oct 2019 10:21:31 +0000 (07:21 -0300)
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

res/res_ari_events.c
rest-api-templates/res_ari_resource.c.mustache

index 04c1c7946f26d37d02eedb7fb44745a2e2c78073..e30c6373e03e268d006ee4b5dd3eed64675bc26e 100644 (file)
@@ -150,6 +150,8 @@ static void ast_ari_events_event_websocket_ws_established_cb(struct ast_websocke
        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");
index 40e18556f7e397dbfd769d72116c0be0cb9fa0ad..6b6502e37b85919ef1d8f8a6ad6a0f466598e329 100644 (file)
@@ -198,6 +198,8 @@ static void ast_ari_{{c_name}}_{{c_nickname}}_ws_established_cb(struct ast_webso
        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) {