From c31058947491ca319c901040219be39e4f8155b6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 19 Oct 2017 13:47:57 +0200 Subject: score: Move thread queue timeout handling Update #3117. Update #3182. --- cpukit/posix/src/mqueuerecvsupp.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'cpukit/posix/src/mqueuerecvsupp.c') diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c index 416e7989fd..c6d1805214 100644 --- a/cpukit/posix/src/mqueuerecvsupp.c +++ b/cpukit/posix/src/mqueuerecvsupp.c @@ -36,18 +36,17 @@ THREAD_QUEUE_OBJECT_ASSERT( */ ssize_t _POSIX_Message_queue_Receive_support( - mqd_t mqdes, - char *msg_ptr, - size_t msg_len, - unsigned int *msg_prio, - bool wait, - Watchdog_Interval timeout + mqd_t mqdes, + char *msg_ptr, + size_t msg_len, + unsigned int *msg_prio, + const struct timespec *abstime, + Thread_queue_Enqueue_callout enqueue_callout ) { POSIX_Message_queue_Control *the_mq; Thread_queue_Context queue_context; size_t length_out; - bool do_wait; Thread_Control *executing; Status_Control status; @@ -67,22 +66,15 @@ ssize_t _POSIX_Message_queue_Receive_support( rtems_set_errno_and_return_minus_one( EMSGSIZE ); } + _Thread_queue_Context_set_enqueue_callout( &queue_context, enqueue_callout ); + _Thread_queue_Context_set_timeout_argument( &queue_context, abstime ); + /* * Now if something goes wrong, we return a "length" of -1 * to indicate an error. */ - length_out = -1; - /* - * A timed receive with a bad time will do a poll regardless. - */ - if ( wait ) { - do_wait = ( the_mq->oflag & O_NONBLOCK ) == 0; - } else { - do_wait = wait; - } - _CORE_message_queue_Acquire_critical( &the_mq->Message_queue, &queue_context @@ -97,13 +89,12 @@ ssize_t _POSIX_Message_queue_Receive_support( * Now perform the actual message receive */ executing = _Thread_Executing; - _Thread_queue_Context_set_relative_timeout( &queue_context, timeout ); status = _CORE_message_queue_Seize( &the_mq->Message_queue, executing, msg_ptr, &length_out, - do_wait, + ( the_mq->oflag & O_NONBLOCK ) == 0, &queue_context ); -- cgit v1.2.3