Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
func_periodic_hook: add module ref counting
Browse files Browse the repository at this point in the history
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.



git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@412279 f38db490-d61c-443f-a65b-d21fe96a405b
  • Loading branch information
russellb committed Apr 12, 2014
1 parent fd0b0d4 commit 3a02aa1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions funcs/func_periodic_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ static void hook_datastore_destroy_callback(void *data)
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 = {
Expand Down Expand Up @@ -298,10 +300,13 @@ static int init_hook(struct ast_channel *chan, const char *context, const char *

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;
}
Expand Down

0 comments on commit 3a02aa1

Please sign in to comment.