[asterisk-commits] dlee: branch dlee/ASTERISK-22296 r397664 - /team/dlee/ASTERISK-22296/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 26 14:02:55 CDT 2013
Author: dlee
Date: Mon Aug 26 14:02:53 2013
New Revision: 397664
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397664
Log:
More res_http_websocket module refcounting fixes
Modified:
team/dlee/ASTERISK-22296/res/res_http_websocket.c
Modified: team/dlee/ASTERISK-22296/res/res_http_websocket.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22296/res/res_http_websocket.c?view=diff&rev=397664&r1=397663&r2=397664
==============================================================================
--- team/dlee/ASTERISK-22296/res/res_http_websocket.c (original)
+++ team/dlee/ASTERISK-22296/res/res_http_websocket.c Mon Aug 26 14:02:53 2013
@@ -733,7 +733,7 @@
ast_websocket_unref(session);
}
-int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol)(const char *name, ast_websocket_callback callback)
+static int websocket_add_protocol_internal(const char *name, ast_websocket_callback callback)
{
struct ast_websocket_server *ws_server = websocketuri.data;
if (!ws_server) {
@@ -742,13 +742,31 @@
return ast_websocket_server_add_protocol(ws_server, name, callback);
}
-int AST_OPTIONAL_API_NAME(ast_websocket_remove_protocol)(const char *name, ast_websocket_callback callback)
+int AST_OPTIONAL_API_NAME(ast_websocket_add_protocol)(const char *name, ast_websocket_callback callback)
+{
+ int res = websocket_add_protocol_internal(name, callback);
+ if (res == 0) {
+ ast_module_ref(ast_module_info->self);
+ }
+ return res;
+}
+
+static int websocket_remove_protocol_internal(const char *name, ast_websocket_callback callback)
{
struct ast_websocket_server *ws_server = websocketuri.data;
if (!ws_server) {
return -1;
}
return ast_websocket_server_remove_protocol(ws_server, name, callback);
+}
+
+int AST_OPTIONAL_API_NAME(ast_websocket_remove_protocol)(const char *name, ast_websocket_callback callback)
+{
+ int res = websocket_remove_protocol_internal(name, callback);
+ if (res == 0) {
+ ast_module_unref(ast_module_info->self);
+ }
+ return res;
}
static int load_module(void)
@@ -758,7 +776,7 @@
return AST_MODULE_LOAD_FAILURE;
}
ast_http_uri_link(&websocketuri);
- ast_websocket_add_protocol("echo", websocket_echo_callback);
+ websocket_add_protocol_internal("echo", websocket_echo_callback);
return 0;
}
More information about the asterisk-commits
mailing list