From c904df573396d95957dc79b242b3a76911063089 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 18 Mar 2016 07:25:23 +0100 Subject: 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. --- cpukit/posix/src/mqueueunlink.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'cpukit/posix/src/mqueueunlink.c') 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 - -#include -#include -#include -#include #include -#include -#include -#include -#include #include +#include /* * 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; } -- cgit v1.2.3