diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-10-25 23:58:32 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-10-25 23:58:32 +0000 |
commit | 78790f0d58c6206e6ca4031c427e8fe623678531 (patch) | |
tree | b50798e8c4817f61f31831fe0cf9d49d859bd1b0 /main/taskprocessor.c | |
parent | 7eea4ab872282088f8229ad679c552392e95cb26 (diff) |
taskprocessor: Made use pthread_equal() to compare thread ids.
* Removed another silly use of RAII_VAR(). RAII_VAR() and SCOPED_LOCK()
are not silver bullets that allow you to turn off your brain.
........
Merged revisions 402044 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402045 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/taskprocessor.c')
-rw-r--r-- | main/taskprocessor.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/main/taskprocessor.c b/main/taskprocessor.c index 189219d66..ac8df9772 100644 --- a/main/taskprocessor.c +++ b/main/taskprocessor.c @@ -232,17 +232,17 @@ static void default_listener_shutdown(struct ast_taskprocessor_listener *listene ast_taskprocessor_push(listener->tps, default_listener_die, pvt); - if (pthread_self() == pvt->poll_thread) { + ast_assert(pvt->poll_thread != AST_PTHREADT_NULL); + + if (pthread_equal(pthread_self(), pvt->poll_thread)) { res = pthread_detach(pvt->poll_thread); if (res != 0) { - ast_log(LOG_ERROR, "pthread_detach(): %s\n", - strerror(errno)); + ast_log(LOG_ERROR, "pthread_detach(): %s\n", strerror(errno)); } } else { res = pthread_join(pvt->poll_thread, NULL); if (res != 0) { - ast_log(LOG_ERROR, "pthread_join(): %s\n", - strerror(errno)); + ast_log(LOG_ERROR, "pthread_join(): %s\n", strerror(errno)); } } pvt->poll_thread = AST_PTHREADT_NULL; @@ -538,18 +538,15 @@ static void taskprocessor_listener_dtor(void *obj) struct ast_taskprocessor_listener *ast_taskprocessor_listener_alloc(const struct ast_taskprocessor_listener_callbacks *callbacks, void *user_data) { - RAII_VAR(struct ast_taskprocessor_listener *, listener, - NULL, ao2_cleanup); + struct ast_taskprocessor_listener *listener; listener = ao2_alloc(sizeof(*listener), taskprocessor_listener_dtor); - if (!listener) { return NULL; } listener->callbacks = callbacks; listener->user_data = user_data; - ao2_ref(listener, +1); return listener; } |