source: rtems/cpukit/posix/src/mqueueunlink.c @ 23fec9f0

4.115
Last change on this file since 23fec9f0 was 23fec9f0, checked in by Sebastian Huber <sebastian.huber@…>, on 03/27/14 at 13:16:12

score: PR2152: Use allocator mutex for objects

Use allocator mutex for objects allocate/free. This prevents that the
thread dispatch latency depends on the workspace/heap fragmentation.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief Remove a Message Queue
5 * @ingroup POSIX_MQUEUE Message Queues
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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#include <rtems/posix/time.h>
35
36/*
37 *  15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276
38 */
39
40int mq_unlink(
41  const char *name
42)
43{
44  int                                   status;
45  POSIX_Message_queue_Control          *the_mq;
46  Objects_Id                            the_mq_id;
47  size_t                                name_len;
48
49  _Objects_Allocator_lock();
50  _Thread_Disable_dispatch();
51
52  status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
53   if ( status != 0 ) {
54    _Thread_Enable_dispatch();
55    _Objects_Allocator_unlock();
56    rtems_set_errno_and_return_minus_one( status );
57   }
58
59  the_mq = (POSIX_Message_queue_Control *) _Objects_Get_local_object(
60    &_POSIX_Message_queue_Information,
61    _Objects_Get_index( the_mq_id )
62  );
63
64  the_mq->linked = false;
65  _POSIX_Message_queue_Namespace_remove( the_mq );
66  _POSIX_Message_queue_Delete( the_mq );
67
68  _Thread_Enable_dispatch();
69   _Objects_Allocator_unlock();
70  return 0;
71}
Note: See TracBrowser for help on using the repository browser.