[asterisk-commits] russell: trunk r412279 - /trunk/funcs/func_periodic_hook.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 11 20:26:35 CDT 2014


Author: russell
Date: Fri Apr 11 20:26:28 2014
New Revision: 412279

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=412279
Log:
func_periodic_hook: add module ref counting

This module lacked necessary module ref count incrementing and decrementing
when used.  This patch adds it.  There's already a datastore used, so doing the
ref counting along with the lifetime of the datastore provides a convenient
place to do it.


Modified:
    trunk/funcs/func_periodic_hook.c

Modified: trunk/funcs/func_periodic_hook.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_periodic_hook.c?view=diff&rev=412279&r1=412278&r2=412279
==============================================================================
--- trunk/funcs/func_periodic_hook.c (original)
+++ trunk/funcs/func_periodic_hook.c Fri Apr 11 20:26:28 2014
@@ -135,6 +135,8 @@
 	ast_free(state->context);
 	ast_free(state->exten);
 	ast_free(state);
+
+	ast_module_unref(ast_module_info->self);
 }
 
 static const struct ast_datastore_info hook_datastore = {
@@ -298,10 +300,13 @@
 
 	snprintf(uid, sizeof(uid), "%u", hook_id);
 
+	ast_module_ref(ast_module_info->self);
 	if (!(datastore = ast_datastore_alloc(&hook_datastore, uid))) {
+		ast_module_unref(ast_module_info->self);
 		return -1;
 	}
 	if (!(state = hook_state_alloc(context, exten, interval, hook_id))) {
+		ast_module_unref(ast_module_info->self);
 		ast_datastore_free(datastore);
 		return -1;
 	}




More information about the asterisk-commits mailing list