mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 16:21:01 +00:00
Don't attempt a websocket protocol removal if res_http_websocket isn't there
This patch sets the protocols container provided by res_http_websocket to NULL when the module gets unloaded and adds the necessary checks when adding/ removing a websocket protocol. This prevents some FRACKing on an invalid pointer to the disposed container if a module that uses res_http_websocket is unloaded after it. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@384942 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -122,6 +122,10 @@ int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol)(const char *name, ast_webs
|
||||
{
|
||||
struct websocket_protocol *protocol;
|
||||
|
||||
if (!protocols) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ao2_lock(protocols);
|
||||
|
||||
/* Ensure a second protocol handler is not registered for the same protocol */
|
||||
@@ -157,6 +161,10 @@ int AST_OPTIONAL_API_NAME(ast_websocket_remove_protocol)(const char *name, ast_w
|
||||
{
|
||||
struct websocket_protocol *protocol;
|
||||
|
||||
if (!protocols) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(protocol = ao2_find(protocols, name, OBJ_KEY))) {
|
||||
return -1;
|
||||
}
|
||||
@@ -670,6 +678,7 @@ static int unload_module(void)
|
||||
ast_websocket_remove_protocol("echo", websocket_echo_callback);
|
||||
ast_http_uri_unlink(&websocketuri);
|
||||
ao2_ref(protocols, -1);
|
||||
protocols = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -322,5 +322,6 @@ static int unload_module(void)
|
||||
AST_MODULE_INFO(ASTERISK_GPL_KEY, 0, "Stasis HTTP bindings",
|
||||
.load = load_module,
|
||||
.unload = unload_module,
|
||||
.nonoptreq = "app_stasis,res_http_websocket"
|
||||
.nonoptreq = "app_stasis,res_http_websocket",
|
||||
.load_pri = AST_MODPRI_APP_DEPEND,
|
||||
);
|
||||
|
Reference in New Issue
Block a user