コード例 #1
0
ファイル: mqueueunlink.c プロジェクト: AoLaD/rtems
int mq_unlink(
  const char *name
)
{
  POSIX_Message_queue_Control *the_mq;
  Objects_Get_by_name_error    error;
  Thread_queue_Context         queue_context;

  _Objects_Allocator_lock();

  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( _POSIX_Get_by_name_error( error ) );
  }

  _POSIX_Message_queue_Namespace_remove( the_mq );

  _CORE_message_queue_Acquire( &the_mq->Message_queue, &queue_context );

  the_mq->linked = false;
  _POSIX_Message_queue_Delete( the_mq, &queue_context );

  _Objects_Allocator_unlock();
  return 0;
}
コード例 #2
0
ファイル: mqueueclose.c プロジェクト: vecnatechnologies/rtems
int mq_close(
    mqd_t  mqdes
)
{
    POSIX_Message_queue_Control *the_mq;
    Thread_queue_Context         queue_context;

    _Objects_Allocator_lock();
    the_mq = _POSIX_Message_queue_Get( mqdes, &queue_context );

    if ( the_mq == NULL ) {
        _Objects_Allocator_unlock();
        rtems_set_errno_and_return_minus_one( EBADF );
    }

    _CORE_message_queue_Acquire_critical(
        &the_mq->Message_queue,
        &queue_context
    );

    if ( the_mq->open_count == 0 ) {
        _CORE_message_queue_Release( &the_mq->Message_queue, &queue_context );
        _Objects_Allocator_unlock();
        rtems_set_errno_and_return_minus_one( EBADF );
    }

    the_mq->open_count -= 1;
    _POSIX_Message_queue_Delete( the_mq, &queue_context );

    _Objects_Allocator_unlock();
    return 0;
}
コード例 #3
0
ファイル: mqueueclose.c プロジェクト: 0871087123/rtems
int mq_close(
  mqd_t  mqdes
)
{
  POSIX_Message_queue_Control    *the_mq;
  POSIX_Message_queue_Control_fd *the_mq_fd;
  Objects_Locations               location;

  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
  if ( location == OBJECTS_LOCAL ) {
      /* OBJECTS_LOCAL:
       *
       *  First update the actual message queue to reflect this descriptor
       *  being disassociated.  This may result in the queue being really
       *  deleted.
       */

      the_mq = the_mq_fd->Queue;
      the_mq->open_count -= 1;
      _POSIX_Message_queue_Delete( the_mq );

      /*
       *  Now close this file descriptor.
       */

      _Objects_Close(
        &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object );
      _POSIX_Message_queue_Free_fd( the_mq_fd );

      _Thread_Enable_dispatch();
      return 0;
   }

   /*
    *  OBJECTS_REMOTE:
    *  OBJECTS_ERROR:
    */
   rtems_set_errno_and_return_minus_one( EBADF );
}