summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mqueueunlink.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-18 07:25:23 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-18 15:36:58 +0100
commitc904df573396d95957dc79b242b3a76911063089 (patch)
treebe6406676689018e8af8a929b6a4ef5284f94c70 /cpukit/posix/src/mqueueunlink.c
parentsptests/sptls02: Use GNU++11 (diff)
downloadrtems-c904df573396d95957dc79b242b3a76911063089.tar.bz2
score: Add _Objects_Get_by_name()
Replace _Objects_Name_to_id_string() with _Objects_Get_by_name() since all users of this function are interested in the object itself and not the identifier. Use the object allocator lock to protect the search. Update #2555.
Diffstat (limited to 'cpukit/posix/src/mqueueunlink.c')
-rw-r--r--cpukit/posix/src/mqueueunlink.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/cpukit/posix/src/mqueueunlink.c b/cpukit/posix/src/mqueueunlink.c
index 2be096a421..d5182d21fc 100644
--- a/cpukit/posix/src/mqueueunlink.c
+++ b/cpukit/posix/src/mqueueunlink.c
@@ -18,19 +18,10 @@
#include "config.h"
#endif
-#include <stdarg.h>
-
-#include <pthread.h>
-#include <limits.h>
-#include <errno.h>
-#include <fcntl.h>
#include <mqueue.h>
-#include <rtems/system.h>
-#include <rtems/score/watchdog.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/seterr.h>
#include <rtems/posix/mqueueimpl.h>
+#include <rtems/seterr.h>
/*
* 15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276
@@ -40,31 +31,21 @@ int mq_unlink(
const char *name
)
{
- int status;
- POSIX_Message_queue_Control *the_mq;
- Objects_Id the_mq_id;
- size_t name_len;
+ POSIX_Message_queue_Control *the_mq;
+ Objects_Get_by_name_error error;
_Objects_Allocator_lock();
- _Thread_Disable_dispatch();
- status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
- if ( status != 0 ) {
- _Thread_Enable_dispatch();
+ the_mq = _POSIX_Message_queue_Get_by_name( name, NULL, &error );
+ if ( the_mq == NULL ) {
_Objects_Allocator_unlock();
- rtems_set_errno_and_return_minus_one( status );
- }
-
- the_mq = (POSIX_Message_queue_Control *) _Objects_Get_local_object(
- &_POSIX_Message_queue_Information,
- _Objects_Get_index( the_mq_id )
- );
+ rtems_set_errno_and_return_minus_one( _POSIX_Get_by_name_error( error ) );
+ }
the_mq->linked = false;
_POSIX_Message_queue_Namespace_remove( the_mq );
_POSIX_Message_queue_Delete( the_mq );
- _Thread_Enable_dispatch();
- _Objects_Allocator_unlock();
+ _Objects_Allocator_unlock();
return 0;
}