mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-04 03:20:33 +00:00
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. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@402044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -232,17 +232,17 @@ static void default_listener_shutdown(struct ast_taskprocessor_listener *listene
|
|||||||
|
|
||||||
ast_taskprocessor_push(listener->tps, default_listener_die, pvt);
|
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);
|
res = pthread_detach(pvt->poll_thread);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
ast_log(LOG_ERROR, "pthread_detach(): %s\n",
|
ast_log(LOG_ERROR, "pthread_detach(): %s\n", strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = pthread_join(pvt->poll_thread, NULL);
|
res = pthread_join(pvt->poll_thread, NULL);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
ast_log(LOG_ERROR, "pthread_join(): %s\n",
|
ast_log(LOG_ERROR, "pthread_join(): %s\n", strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pvt->poll_thread = AST_PTHREADT_NULL;
|
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)
|
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,
|
struct ast_taskprocessor_listener *listener;
|
||||||
NULL, ao2_cleanup);
|
|
||||||
|
|
||||||
listener = ao2_alloc(sizeof(*listener), taskprocessor_listener_dtor);
|
listener = ao2_alloc(sizeof(*listener), taskprocessor_listener_dtor);
|
||||||
|
|
||||||
if (!listener) {
|
if (!listener) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
listener->callbacks = callbacks;
|
listener->callbacks = callbacks;
|
||||||
listener->user_data = user_data;
|
listener->user_data = user_data;
|
||||||
|
|
||||||
ao2_ref(listener, +1);
|
|
||||||
return listener;
|
return listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user