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

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


Author: russell
Date: Fri Apr 11 20:35:34 2014
New Revision: 412280

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=412280
Log:
func_periodic_hook: move module ref

The previous code left one error path where the module would be unref'd twice
instead of once.  It was done once in the error handling block, and again inside
of datastore destruction.

Now the module ref is only released in the datastore destructor and only acquired
when the datastore has been successfully allocated.


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=412280&r1=412279&r2=412280
==============================================================================
--- trunk/funcs/func_periodic_hook.c (original)
+++ trunk/funcs/func_periodic_hook.c Fri Apr 11 20:35:34 2014
@@ -300,13 +300,11 @@
 
 	snprintf(uid, sizeof(uid), "%u", hook_id);
 
+	if (!(datastore = ast_datastore_alloc(&hook_datastore, uid))) {
+		return -1;
+	}
 	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