[asterisk-commits] twilson: branch twilson/config_work r366978 - /team/twilson/config_work/apps/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 18 11:26:29 CDT 2012
Author: twilson
Date: Fri May 18 11:26:19 2012
New Revision: 366978
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=366978
Log:
Add a couple of comments to app_skel explaining items and state
Modified:
team/twilson/config_work/apps/app_skel.c
Modified: team/twilson/config_work/apps/app_skel.c
URL: http://svnview.digium.com/svn/asterisk/team/twilson/config_work/apps/app_skel.c?view=diff&rev=366978&r1=366977&r2=366978
==============================================================================
--- team/twilson/config_work/apps/app_skel.c (original)
+++ team/twilson/config_work/apps/app_skel.c Fri May 18 11:26:19 2012
@@ -274,6 +274,14 @@
return item ? 1 : 0;
}
+/*! \brief Look up an existing state object, or create a new one
+ * \internal
+ * \note Since the reload code will create a new item from scratch, it
+ * is important for any state that must persist between reloads to be
+ * in a separate refcounted object. This function allows the item alloc
+ * function to get a ref to an existing state object if it exists,
+ * otherwise it will return a reference to a newly allocated state object.
+ */
static void *skel_find_or_create_state(const char *category)
{
RAII_VAR(struct skel_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
@@ -303,6 +311,10 @@
return NULL;
}
+ /* Since the item has state information that needs to persist between reloads,
+ * it is important to handle that here in the item's allocation function.
+ * If not separated out into its own object, the data would be destroyed on
+ * reload. */
if (!(item->state = skel_find_or_create_state(cat))) {
ao2_ref(item, -1);
return NULL;
More information about the asterisk-commits
mailing list