[asterisk-commits] dhubbard: branch group/taskprocessors r111955 - in /team/group/taskprocessors...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Mar 29 16:03:20 CDT 2008
Author: dhubbard
Date: Sat Mar 29 16:03:19 2008
New Revision: 111955
URL: http://svn.digium.com/view/asterisk?view=rev&rev=111955
Log:
provide ast_taskprocessor_unreference() for better api symmetry
Modified:
team/group/taskprocessors/apps/app_queue.c
team/group/taskprocessors/apps/app_voicemail.c
team/group/taskprocessors/channels/chan_sip.c
team/group/taskprocessors/include/asterisk/taskprocessor.h
team/group/taskprocessors/main/taskprocessor.c
Modified: team/group/taskprocessors/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/apps/app_queue.c?view=diff&rev=111955&r1=111954&r2=111955
==============================================================================
--- team/group/taskprocessors/apps/app_queue.c (original)
+++ team/group/taskprocessors/apps/app_queue.c Sat Mar 29 16:03:19 2008
@@ -6168,7 +6168,7 @@
queue_unref(q);
}
ao2_ref(queues, -1);
- ao2_ref(taskprocessor, -1);
+ ast_taskprocessor_unreference(taskprocessor);
return res;
}
Modified: team/group/taskprocessors/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/apps/app_voicemail.c?view=diff&rev=111955&r1=111954&r2=111955
==============================================================================
--- team/group/taskprocessors/apps/app_voicemail.c (original)
+++ team/group/taskprocessors/apps/app_voicemail.c Sat Mar 29 16:03:19 2008
@@ -9011,7 +9011,7 @@
if (poll_thread != AST_PTHREADT_NULL)
stop_poll_thread();
- ao2_ref(taskprocessor, -1);
+ ast_taskprocessor_unreference(taskprocessor);
return res;
}
Modified: team/group/taskprocessors/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/channels/chan_sip.c?view=diff&rev=111955&r1=111954&r2=111955
==============================================================================
--- team/group/taskprocessors/channels/chan_sip.c (original)
+++ team/group/taskprocessors/channels/chan_sip.c Sat Mar 29 16:03:19 2008
@@ -21568,7 +21568,7 @@
struct sip_threadinfo *th;
struct ast_context *con;
- ao2_ref(taskprocessor, -1);
+ ast_taskprocessor_unreference(taskprocessor);
/* First, take us out of the channel type list */
ast_channel_unregister(&sip_tech);
Modified: team/group/taskprocessors/include/asterisk/taskprocessor.h
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/include/asterisk/taskprocessor.h?view=diff&rev=111955&r1=111954&r2=111955
==============================================================================
--- team/group/taskprocessors/include/asterisk/taskprocessor.h (original)
+++ team/group/taskprocessors/include/asterisk/taskprocessor.h Sat Mar 29 16:03:19 2008
@@ -108,6 +108,9 @@
/*! \brief Obtain a taskprocessor reference */
struct ast_taskprocessor *ast_taskprocessor_reference(const char *name, void *(*func)(void*));
+/*! \brief Release a taskprocessor reference */
+int ast_taskprocessor_unreference(struct ast_taskprocessor *tps);
+
/*! \brief Push a task on the taskprocessor */
int ast_taskprocessor_push(struct ast_taskprocessor *tp, struct ast_task *t);
/*! \brief Pop the front task off the taskprocessor queue and return it to the calling function */
Modified: team/group/taskprocessors/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/main/taskprocessor.c?view=diff&rev=111955&r1=111954&r2=111955
==============================================================================
--- team/group/taskprocessors/main/taskprocessor.c (original)
+++ team/group/taskprocessors/main/taskprocessor.c Sat Mar 29 16:03:19 2008
@@ -319,7 +319,7 @@
tps->_stats = ast_calloc(1, sizeof(*tps->_stats));
if (!tps->_stats) {
ast_log(LOG_ERROR, "cannot allocate memory for a ast_taskprocessor_stats structure.\n");
- ao2_ref(tps, -1);
+ ast_taskprocessor_unreference(tps);
return NULL;
}
return tps;
@@ -360,18 +360,18 @@
snprintf(p->_name, sizeof(p->_name), "%s", name);
if (tps_taskprocessor_add(p) < 0) {
ast_log(LOG_ERROR, "can't add taskprocessor_singleton \'%s\' with ID: 0x%X\n", p->_name, (unsigned int)p->_id);
- ao2_ref(p, -1);
+ ast_taskprocessor_unreference(p);
return NULL;
}
p->_poll_thread_run = 1;
ast_debug(5, "creating taskprocessor \'%s\', taskprocessor count: %d\n", name, tps_taskprocessor_count());
/* stay stopped if we are supposed to be stopped */
if (p->_poll_thread == AST_PTHREADT_STOP) {
- ao2_ref(p, -1);
+ ast_taskprocessor_unreference(p);
return NULL;
}
if (p->_poll_thread == pthread_self()) {
- ao2_ref(p, -1);
+ ast_taskprocessor_unreference(p);
return NULL;
}
if (p->_poll_thread != AST_PTHREADT_NULL) {
@@ -389,11 +389,21 @@
}
if (rc < 0) {
ast_log(LOG_ERROR, "failed to create thread \'%s\'.\n", p->_name);
- ao2_ref(p, -1);
+ ast_taskprocessor_unreference(p);
return NULL;
}
}
return p;
+}
+
+int ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
+{
+ if (!tps) {
+ ast_log(LOG_ERROR, "You must specify the taskprocessor that you want to unreference\n");
+ return -1;
+ }
+ ao2_ref(tps, -1);
+ return 0;
}
/*! \brief The taskprocessor destructor is called by astobj2 when the reference count reaches zero
More information about the asterisk-commits
mailing list