diff options
author | Matthew Jordan <mjordan@digium.com> | 2013-04-08 15:38:34 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2013-04-08 15:38:34 +0000 |
commit | a5df2542c34544d4a274303c0c26581dbca5c301 (patch) | |
tree | b04f265c3e97be56492e65b4a48a6eb572c0ac93 /res/res_http_websocket.c | |
parent | b8d4e573f1292688d07063542d263490536c2bc9 (diff) |
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
Diffstat (limited to 'res/res_http_websocket.c')
-rw-r--r-- | res/res_http_websocket.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c index cfc6d16f5..15ff8fa45 100644 --- a/res/res_http_websocket.c +++ b/res/res_http_websocket.c @@ -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; } |