score: _CORE_message_queue_Close()

Move lock acquire to caller of _CORE_message_queue_Close() to allow
state checks during object close operations under lock protection.
Ensures deletion safety on uni-processor configuration.
This commit is contained in:
Sebastian Huber
2016-05-02 07:46:14 +02:00
parent dd6c28eee0
commit 7580995b47
4 changed files with 36 additions and 27 deletions
+5 -1
View File
@@ -41,6 +41,7 @@ void _POSIX_Message_queue_Delete(
{
if ( !the_mq->linked && !the_mq->open_count ) {
Objects_Control *the_object = &the_mq->Object;
ISR_lock_Context lock_context;
#if defined(RTEMS_DEBUG)
/*
@@ -55,12 +56,15 @@ void _POSIX_Message_queue_Delete(
}
#endif
_CORE_message_queue_Acquire( &the_mq->Message_queue, &lock_context );
_Objects_Close( &_POSIX_Message_queue_Information, the_object );
_CORE_message_queue_Close(
&the_mq->Message_queue,
NULL, /* no MP support */
0
0,
&lock_context
);
_POSIX_Message_queue_Free( the_mq );
+14 -13
View File
@@ -18,17 +18,8 @@
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/score/chain.h>
#include <rtems/score/isr.h>
#include <rtems/score/coremsgimpl.h>
#include <rtems/score/thread.h>
#include <rtems/score/wkspace.h>
#include <rtems/rtems/status.h>
#include <rtems/rtems/attrimpl.h>
#include <rtems/rtems/messageimpl.h>
#include <rtems/rtems/options.h>
#include <rtems/rtems/support.h>
#include <rtems/rtems/attrimpl.h>
rtems_status_code rtems_message_queue_delete(
rtems_id id
@@ -36,19 +27,30 @@ rtems_status_code rtems_message_queue_delete(
{
Message_queue_Control *the_message_queue;
Objects_Locations location;
ISR_lock_Context lock_context;
_Objects_Allocator_lock();
the_message_queue = _Message_queue_Get( id, &location );
the_message_queue = _Message_queue_Get_interrupt_disable(
id,
&location,
&lock_context
);
switch ( location ) {
case OBJECTS_LOCAL:
_CORE_message_queue_Acquire_critical(
&the_message_queue->message_queue,
&lock_context
);
_Objects_Close( &_Message_queue_Information,
&the_message_queue->Object );
_CORE_message_queue_Close(
&the_message_queue->message_queue,
_Message_queue_MP_Send_object_was_deleted,
id
id,
&lock_context
);
#if defined(RTEMS_MULTIPROCESSING)
@@ -66,7 +68,6 @@ rtems_status_code rtems_message_queue_delete(
);
}
#endif
_Objects_Put( &the_message_queue->Object );
_Message_queue_Free( the_message_queue );
_Objects_Allocator_unlock();
return RTEMS_SUCCESSFUL;
+13 -7
View File
@@ -129,12 +129,12 @@ bool _CORE_message_queue_Initialize(
);
void _CORE_message_queue_Do_close(
CORE_message_queue_Control *the_message_queue
CORE_message_queue_Control *the_message_queue,
#if defined(RTEMS_MULTIPROCESSING)
,
Thread_queue_MP_callout mp_callout,
Objects_Id mp_id
Objects_Id mp_id,
#endif
ISR_lock_Context *lock_context
);
/**
@@ -151,26 +151,32 @@ void _CORE_message_queue_Do_close(
* @param[in] mp_callout is the routine to call for each thread
* that is extracted from the set of waiting threads
* @param[in] mp_id the object identifier of the message queue object
* @param[in] lock_context The lock context of the
* _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical().
*/
#if defined(RTEMS_MULTIPROCESSING)
#define _CORE_message_queue_Close( \
the_message_queue, \
mp_callout, \
mp_id \
mp_id, \
lock_context \
) \
_CORE_message_queue_Do_close( \
the_message_queue, \
mp_callout, \
mp_id \
mp_id, \
lock_context \
)
#else
#define _CORE_message_queue_Close( \
the_message_queue, \
mp_callout, \
mp_id \
mp_id, \
lock_context \
) \
_CORE_message_queue_Do_close( \
the_message_queue \
the_message_queue, \
lock_context \
)
#endif
+4 -6
View File
@@ -33,29 +33,27 @@ static Thread_Control *_CORE_message_queue_Was_deleted(
}
void _CORE_message_queue_Do_close(
CORE_message_queue_Control *the_message_queue
CORE_message_queue_Control *the_message_queue,
#if defined(RTEMS_MULTIPROCESSING)
,
Thread_queue_MP_callout mp_callout,
Objects_Id mp_id
Objects_Id mp_id,
#endif
ISR_lock_Context *lock_context
)
{
ISR_lock_Context lock_context;
/*
* This will flush blocked threads whether they were blocked on
* a send or receive.
*/
_CORE_message_queue_Acquire( the_message_queue, &lock_context );
_Thread_queue_Flush_critical(
&the_message_queue->Wait_queue.Queue,
the_message_queue->operations,
_CORE_message_queue_Was_deleted,
mp_callout,
mp_id,
&lock_context
lock_context
);
(void) _Workspace_Free( the_message_queue->message_buffers );