1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief POSIX Delete Message Queue |
---|
5 | * @ingroup POSIX_MQUEUE |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2009. |
---|
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 <stdarg.h> |
---|
22 | |
---|
23 | #include <pthread.h> |
---|
24 | #include <limits.h> |
---|
25 | #include <errno.h> |
---|
26 | #include <fcntl.h> |
---|
27 | #include <mqueue.h> |
---|
28 | |
---|
29 | #include <rtems/system.h> |
---|
30 | #include <rtems/score/watchdog.h> |
---|
31 | #include <rtems/score/wkspace.h> |
---|
32 | #include <rtems/seterr.h> |
---|
33 | #include <rtems/posix/mqueueimpl.h> |
---|
34 | #if defined(RTEMS_DEBUG) |
---|
35 | #include <rtems/bspIo.h> |
---|
36 | #endif |
---|
37 | |
---|
38 | void _POSIX_Message_queue_Delete( |
---|
39 | POSIX_Message_queue_Control *the_mq |
---|
40 | ) |
---|
41 | { |
---|
42 | if ( !the_mq->linked && !the_mq->open_count ) { |
---|
43 | Objects_Control *the_object = &the_mq->Object; |
---|
44 | ISR_lock_Context lock_context; |
---|
45 | |
---|
46 | #if defined(RTEMS_DEBUG) |
---|
47 | /* |
---|
48 | * the name memory will have been freed by unlink. |
---|
49 | */ |
---|
50 | if ( the_object->name.name_p ) { |
---|
51 | printk( |
---|
52 | "POSIX MQ name (%p) not freed by unlink\n", |
---|
53 | (void *)the_object->name.name_p |
---|
54 | ); |
---|
55 | _Workspace_Free( (void *)the_object->name.name_p ); |
---|
56 | } |
---|
57 | #endif |
---|
58 | |
---|
59 | _CORE_message_queue_Acquire( &the_mq->Message_queue, &lock_context ); |
---|
60 | |
---|
61 | _Objects_Close( &_POSIX_Message_queue_Information, the_object ); |
---|
62 | |
---|
63 | _CORE_message_queue_Close( |
---|
64 | &the_mq->Message_queue, |
---|
65 | NULL, /* no MP support */ |
---|
66 | 0, |
---|
67 | &lock_context |
---|
68 | ); |
---|
69 | |
---|
70 | _POSIX_Message_queue_Free( the_mq ); |
---|
71 | |
---|
72 | } |
---|
73 | } |
---|