1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Close a Message Queue |
---|
5 | * @ingroup ScoreMessageQueue |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/score/coremsgimpl.h> |
---|
22 | #include <rtems/score/wkspace.h> |
---|
23 | |
---|
24 | static Thread_Control *_CORE_message_queue_Was_deleted( |
---|
25 | Thread_Control *the_thread, |
---|
26 | Thread_queue_Queue *queue, |
---|
27 | ISR_lock_Context *lock_context |
---|
28 | ) |
---|
29 | { |
---|
30 | the_thread->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED; |
---|
31 | |
---|
32 | return the_thread; |
---|
33 | } |
---|
34 | |
---|
35 | void _CORE_message_queue_Do_close( |
---|
36 | CORE_message_queue_Control *the_message_queue, |
---|
37 | #if defined(RTEMS_MULTIPROCESSING) |
---|
38 | Thread_queue_MP_callout mp_callout, |
---|
39 | #endif |
---|
40 | ISR_lock_Context *lock_context |
---|
41 | ) |
---|
42 | { |
---|
43 | |
---|
44 | /* |
---|
45 | * This will flush blocked threads whether they were blocked on |
---|
46 | * a send or receive. |
---|
47 | */ |
---|
48 | |
---|
49 | _Thread_queue_Flush_critical( |
---|
50 | &the_message_queue->Wait_queue.Queue, |
---|
51 | the_message_queue->operations, |
---|
52 | _CORE_message_queue_Was_deleted, |
---|
53 | mp_callout, |
---|
54 | lock_context |
---|
55 | ); |
---|
56 | |
---|
57 | (void) _Workspace_Free( the_message_queue->message_buffers ); |
---|
58 | |
---|
59 | _Thread_queue_Destroy( &the_message_queue->Wait_queue ); |
---|
60 | } |
---|