[asterisk-commits] dlee: branch dlee/ASTERISK-22296 r397663 - /team/dlee/ASTERISK-22296/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 26 13:34:54 CDT 2013


Author: dlee
Date: Mon Aug 26 13:34:52 2013
New Revision: 397663

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397663
Log:
Fix use count on res_http_websocket

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=397663&r1=397662&r2=397663
==============================================================================
--- team/dlee/ASTERISK-22296/res/res_http_websocket.c (original)
+++ team/dlee/ASTERISK-22296/res/res_http_websocket.c Mon Aug 26 13:34:52 2013
@@ -107,14 +107,20 @@
 	struct ao2_container *protocols; /*!< Container for registered protocols */
 };
 
-static void websocket_server_dtor(void *obj)
+static void websocket_server_internal_dtor(void *obj)
 {
 	struct ast_websocket_server *server = obj;
 	ao2_cleanup(server->protocols);
 	server->protocols = NULL;
 }
 
-struct ast_websocket_server *ast_websocket_server_create(void)
+static void websocket_server_dtor(void *obj)
+{
+	websocket_server_internal_dtor(obj);
+	ast_module_unref(ast_module_info->self);
+}
+
+static struct ast_websocket_server *ast_websocket_server_internal_create(void)
 {
 	RAII_VAR(struct ast_websocket_server *, server, NULL, ao2_cleanup);
 
@@ -130,6 +136,12 @@
 
 	ao2_ref(server, +1);
 	return server;
+}
+
+struct ast_websocket_server *ast_websocket_server_create(void)
+{
+	ast_module_ref(ast_module_info->self);
+	return ast_websocket_server_internal_create();
 }
 
 /*! \brief Destructor function for sessions */
@@ -520,6 +532,8 @@
 	struct websocket_protocol *protocol_handler = NULL;
 	struct ast_websocket *session;
 	struct ast_websocket_server *server;
+
+	SCOPED_MODULE_USE(ast_module_info->self);
 
 	/* Upgrade requests are only permitted on GET methods */
 	if (method != AST_HTTP_GET) {
@@ -739,7 +753,7 @@
 
 static int load_module(void)
 {
-	websocketuri.data = ast_websocket_server_create();
+	websocketuri.data = ast_websocket_server_internal_create();
 	if (!websocketuri.data) {
 		return AST_MODULE_LOAD_FAILURE;
 	}




More information about the asterisk-commits mailing list