From e047162803ea35efc00559d236891d1cfe1a7de8 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 20 Sep 2018 16:21:37 +0200 Subject: [PATCH] fix a bug when Linux kernel is busy --- common/utils/ocp_itti/intertask_interface.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index 13bf801668..5b8d1a430e 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -116,15 +116,14 @@ extern "C" { pthread_mutex_lock (&t->queue_cond_lock); int ret=itti_send_msg_to_task_locked(destination_task_id, instance, message); - // while ( t->message_queue.size()>0 && t->admin.func != NULL ) - if ( t->message_queue.size()>0 && t->admin.func != NULL ) { + while ( t->message_queue.size()>0 && t->admin.func != NULL ) { if (t->message_queue.size()>1) LOG_W(TMR,"queue in no thread mode is %ld\n", t->message_queue.size()); pthread_mutex_unlock (&t->queue_cond_lock); t->admin.func(NULL); - } else { - pthread_mutex_unlock (&t->queue_cond_lock); - } + pthread_mutex_lock (&t->queue_cond_lock); + } + pthread_mutex_unlock (&t->queue_cond_lock); return ret; } @@ -198,6 +197,8 @@ extern "C" { pthread_mutex_unlock(&t->queue_cond_lock); LOG_D(TMR,"enter blocking wait for %s\n", itti_get_task_name(task_id)); t->nb_events = epoll_wait(t->epoll_fd,t->events,t->nb_fd_epoll, epoll_timeout); + if ( t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) ) + pthread_mutex_lock(&t->queue_cond_lock); } while (t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) ); AssertFatal (t->nb_events >=0,