source: rtems/cpukit/posix/src/semdestroy.c @ 1047f37

4.115
Last change on this file since 1047f37 was 1047f37, checked in by Joel Sherrill <joel.sherrill@…>, on 04/14/15 at 17:11:51

semdestroy.c: Add missing _Objects_Allocator_unlock()

closes 2319.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Destroy an Unnamed Semaphore
5 *  @ingroup POSIX_SEMAPHORE
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 <errno.h>
24#include <fcntl.h>
25#include <pthread.h>
26#include <semaphore.h>
27#include <limits.h>
28
29#include <rtems/system.h>
30#include <rtems/posix/semaphoreimpl.h>
31#include <rtems/posix/time.h>
32#include <rtems/seterr.h>
33
34int sem_destroy(
35  sem_t *sem
36)
37{
38  POSIX_Semaphore_Control          *the_semaphore;
39  Objects_Locations                 location;
40
41  _Objects_Allocator_lock();
42  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
43  switch ( location ) {
44
45    case OBJECTS_LOCAL:
46      /*
47       *  Undefined operation on a named semaphore. Release the object
48       *  and fall to the EINVAL return at the bottom.
49       */
50      if ( the_semaphore->named == true ) {
51        _Objects_Put( &the_semaphore->Object );
52      } else {
53        _POSIX_Semaphore_Delete( the_semaphore );
54        _Objects_Put( &the_semaphore->Object );
55        _Objects_Allocator_unlock();
56        return 0;
57      }
58
59#if defined(RTEMS_MULTIPROCESSING)
60    case OBJECTS_REMOTE:
61#endif
62    case OBJECTS_ERROR:
63      break;
64  }
65
66  _Objects_Allocator_unlock();
67
68  rtems_set_errno_and_return_minus_one( EINVAL );
69}
Note: See TracBrowser for help on using the repository browser.