Changeset 53092d1 in rtems


Ignore:
Timestamp:
Apr 26, 2002, 11:39:01 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
7ae7cf7
Parents:
e6ff222
Message:

2001-04-26 Joel Sherrill <joel@…>

  • include/rtems/posix/mqueue.h, inline/rtems/posix/mqueue.inl, src/mqueue.c, src/mqueueclose.c, src/mqueuecreatesupp.c, src/mqueuegetattr.c, src/mqueuenotify.c, src/mqueueopen.c, src/mqueuerecvsupp.c, src/mqueuesendsupp.c, src/mqueuesetattr.c: Per PR81 reworked to add a message queue descriptor separate from the underlying message queue. This allows non-blocking to follow the "open" not the underlying queue.
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/posix/ChangeLog

    re6ff222 r53092d1  
     12001-04-26      Joel Sherrill <joel@OARcorp.com>
     2
     3        * include/rtems/posix/mqueue.h, inline/rtems/posix/mqueue.inl,
     4        src/mqueue.c, src/mqueueclose.c, src/mqueuecreatesupp.c,
     5        src/mqueuegetattr.c, src/mqueuenotify.c, src/mqueueopen.c,
     6        src/mqueuerecvsupp.c, src/mqueuesendsupp.c, src/mqueuesetattr.c:
     7        Per PR81 reworked to add a message queue descriptor separate from
     8        the underlying message queue.  This allows non-blocking to follow
     9        the "open" not the underlying queue.
     10 
    1112002-04-06      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    212
  • c/src/exec/posix/include/rtems/posix/mqueue.h

    re6ff222 r53092d1  
    3535   boolean                     named;
    3636   boolean                     linked;
    37    int                         oflag;
    3837   unsigned32                  open_count;
    3938   CORE_message_queue_Control  Message_queue;
     
    4140}  POSIX_Message_queue_Control;
    4241
     42typedef struct {
     43   Objects_Control              Object;
     44   POSIX_Message_queue_Control *Queue;
     45   int                          oflag;
     46} POSIX_Message_queue_Control_fd;
     47
    4348/*
    4449 *  The following defines the information control block used to manage
    45  *  this class of objects.
     50 *  this class of objects.  The second item is used to manage the set
     51 *  of "file descriptors" associated with the message queues.
    4652 */
    4753 
    4854POSIX_EXTERN Objects_Information  _POSIX_Message_queue_Information;
     55POSIX_EXTERN Objects_Information  _POSIX_Message_queue_Information_fds;
    4956 
    5057/*
     
    7380  const char                    *name,
    7481  int                            pshared,
    75   unsigned int                   oflag,
    7682  struct mq_attr                *attr,
    7783  POSIX_Message_queue_Control  **message_queue
     
    183189 *  DESCRIPTION:
    184190 *
    185  *  XXX
     191 *  This routine looks up the specified name for a message queue and returns the
     192 *  id of the message queue associated with it.
    186193 */
    187194
  • c/src/exec/posix/inline/rtems/posix/mqueue.inl

    re6ff222 r53092d1  
    2222 */
    2323 
    24 RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Allocate( void )
     24RTEMS_INLINE_ROUTINE
     25  POSIX_Message_queue_Control *_POSIX_Message_queue_Allocate( void )
    2526{
    2627  return (POSIX_Message_queue_Control *)
    2728    _Objects_Allocate( &_POSIX_Message_queue_Information );
     29}
     30 
     31/*PAGE
     32 *
     33 *  _POSIX_Message_queue_Allocate_fd
     34 */
     35 
     36RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *
     37  _POSIX_Message_queue_Allocate_fd( void )
     38{
     39  return (POSIX_Message_queue_Control_fd *)
     40    _Objects_Allocate( &_POSIX_Message_queue_Information_fds );
    2841}
    2942 
     
    3851{
    3952  _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object );
     53}
     54
     55/*PAGE
     56 *
     57 *  _POSIX_Message_queue_Free_fd
     58 */
     59 
     60RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free_fd (
     61  POSIX_Message_queue_Control_fd *the_mq_fd
     62)
     63{
     64  _Objects_Free( &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object );
    4065}
    4166
     
    6590  return (POSIX_Message_queue_Control *)
    6691    _Objects_Get( &_POSIX_Message_queue_Information, id, location );
     92}
     93 
     94/*PAGE
     95 *
     96 *  _POSIX_Message_queue_Get_fd
     97 */
     98 
     99RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *_POSIX_Message_queue_Get_fd (
     100  Objects_Id         id,
     101  Objects_Locations *location
     102)
     103{
     104  return (POSIX_Message_queue_Control_fd *)
     105    _Objects_Get( &_POSIX_Message_queue_Information_fds, id, location );
    67106}
    68107 
  • c/src/exec/posix/src/mqueue.c

    re6ff222 r53092d1  
    5959    FALSE
    6060  );
     61  _Objects_Initialize_information(
     62    &_POSIX_Message_queue_Information_fds,
     63    OBJECTS_POSIX_MESSAGE_QUEUE_FDS,
     64    FALSE,
     65    maximum_message_queues,
     66    sizeof( POSIX_Message_queue_Control_fd ),
     67    FALSE,
     68    0,
     69    FALSE
     70  );
    6171}
  • c/src/exec/posix/src/mqueueclose.c

    re6ff222 r53092d1  
    4242)
    4343{
    44   register POSIX_Message_queue_Control *the_mq;
    45   Objects_Locations                     location;
     44  POSIX_Message_queue_Control    *the_mq;
     45  POSIX_Message_queue_Control_fd *the_mq_fd;
     46  Objects_Locations               location;
    4647 
    47   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     48  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    4849  switch ( location ) {
    4950    case OBJECTS_ERROR:
     
    5455      rtems_set_errno_and_return_minus_one( EINVAL );
    5556    case OBJECTS_LOCAL:
     57      /*
     58       *  First update the actual message queue to reflect this descriptor
     59       *  being disassociated.  This may result in the queue being really
     60       *  deleted.
     61       */
     62
     63      the_mq = the_mq_fd->Queue;
    5664      the_mq->open_count -= 1;
    5765      _POSIX_Message_queue_Delete( the_mq );
     66
     67      /*
     68       *  Now close this file descriptor.
     69       */
     70
     71      _Objects_Close(
     72        &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object );
     73      _POSIX_Message_queue_Free_fd( the_mq_fd );
     74
    5875      _Thread_Enable_dispatch();
    5976      return 0;
  • c/src/exec/posix/src/mqueuecreatesupp.c

    re6ff222 r53092d1  
    4242 
    4343int _POSIX_Message_queue_Create_support(
    44   const char                    *name,
     44  const char                    *_name,
    4545  int                            pshared,
    46   unsigned int                   oflag,
    4746  struct mq_attr                *attr_ptr,
    4847  POSIX_Message_queue_Control  **message_queue
     
    5251  CORE_message_queue_Attributes *the_mq_attr;
    5352  struct mq_attr                 attr;
     53  char *name;
    5454
    5555  _Thread_Disable_dispatch();
     
    9696 
    9797  the_mq->process_shared  = pshared;
    98   the_mq->oflag = oflag;
    9998  the_mq->named = TRUE;
    10099  the_mq->open_count = 1;
     
    134133  }
    135134
     135  name = malloc(256);
     136  strcpy( name, _name );
    136137  _Objects_Open(
    137138    &_POSIX_Message_queue_Information,
  • c/src/exec/posix/src/mqueuegetattr.c

    re6ff222 r53092d1  
    4343)
    4444{
    45   register POSIX_Message_queue_Control *the_mq;
     45  POSIX_Message_queue_Control          *the_mq;
     46  POSIX_Message_queue_Control_fd       *the_mq_fd;
    4647  Objects_Locations                     location;
    4748  CORE_message_queue_Attributes        *the_mq_attr;
     
    5051    rtems_set_errno_and_return_minus_one( EINVAL );
    5152
    52   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     53  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    5354  switch ( location ) {
    5455    case OBJECTS_ERROR:
     
    5960      rtems_set_errno_and_return_minus_one( EINVAL );
    6061    case OBJECTS_LOCAL:
     62      the_mq = the_mq_fd->Queue;
     63
    6164      /*
    6265       *  Return the old values.
    6366       */
    6467 
    65       /* XXX this is the same stuff as is in mq_setattr... and probably */
    66       /* XXX should be in an inlined private routine */
    67  
    6868      the_mq_attr = &the_mq->Message_queue.Attributes;
    6969 
    70       mqstat->mq_flags   = the_mq->oflag;
     70      mqstat->mq_flags   = the_mq_fd->oflag;
    7171      mqstat->mq_msgsize = the_mq->Message_queue.maximum_message_size;
    7272      mqstat->mq_maxmsg  = the_mq->Message_queue.maximum_pending_messages;
  • c/src/exec/posix/src/mqueuenotify.c

    re6ff222 r53092d1  
    6565)
    6666{
    67   register POSIX_Message_queue_Control *the_mq;
    68   Objects_Locations                     location;
     67  POSIX_Message_queue_Control    *the_mq;
     68  POSIX_Message_queue_Control_fd *the_mq_fd;
     69  Objects_Locations               location;
    6970 
    70   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     71  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    7172  switch ( location ) {
    7273    case OBJECTS_ERROR:
     
    7778      rtems_set_errno_and_return_minus_one( EINVAL );
    7879    case OBJECTS_LOCAL:
     80      the_mq = the_mq_fd->Queue;
     81
    7982      if ( notification ) {
    8083        if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
  • c/src/exec/posix/src/mqueueopen.c

    re6ff222 r53092d1  
    4646)
    4747{
    48   va_list                        arg;
    49   mode_t                         mode;
    50   struct mq_attr                *attr = NULL;
    51   int                            status;
    52   Objects_Id                     the_mq_id;
    53   POSIX_Message_queue_Control   *the_mq;
    54   Objects_Locations              location;
     48  va_list                         arg;
     49  mode_t                          mode;
     50  struct mq_attr                 *attr = NULL;
     51  int                             status;
     52  Objects_Id                      the_mq_id;
     53  POSIX_Message_queue_Control    *the_mq;
     54  POSIX_Message_queue_Control_fd *the_mq_fd;
     55  Objects_Locations               location;
    5556 
    5657  _Thread_Disable_dispatch();
     
    6364  }
    6465 
     66  the_mq_fd = _POSIX_Message_queue_Allocate_fd();
     67  if ( !the_mq_fd ) {
     68    _Thread_Enable_dispatch();
     69    rtems_set_errno_and_return_minus_one( ENFILE );
     70  }
     71  the_mq_fd->oflag = oflag;
     72
    6573  status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
    66  
     74
    6775  /*
    6876   *  If the name to id translation worked, then the message queue exists
     
    8088
    8189    if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
     90      _POSIX_Message_queue_Free_fd( the_mq_fd );
    8291      _Thread_Enable_dispatch();
    8392      rtems_set_errno_and_return_minus_one_cast( status, mqd_t );
     
    91100
    92101    if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
     102      _POSIX_Message_queue_Free_fd( the_mq_fd );
    93103      _Thread_Enable_dispatch();
    94104      rtems_set_errno_and_return_minus_one_cast( EEXIST, mqd_t );
     
    96106
    97107    /*
    98      * XXX In this case we need to do an ID->pointer conversion to
    99      *     check the mode.   This is probably a good place for a subroutine.
     108     * In this case we need to do an ID->pointer conversion to
     109     * check the mode.
    100110     */
    101111
    102112    the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
    103113    the_mq->open_count += 1;
     114    the_mq_fd->Queue = the_mq;
    104115    _Thread_Enable_dispatch();
    105116    _Thread_Enable_dispatch();
    106     return (mqd_t)the_mq->Object.id;
     117    return (mqd_t)the_mq_fd->Object.id;
    107118 
    108119  }
     
    116127    name,
    117128    TRUE,         /* shared across processes */
    118     oflag,
    119129    attr,
    120130    &the_mq
     
    125135   */
    126136
     137  if ( status == -1 ) {
     138    _Thread_Enable_dispatch();
     139    _POSIX_Message_queue_Free_fd( the_mq_fd );
     140    return (mqd_t) -1;
     141  }
     142 
     143  the_mq_fd->Queue = the_mq;
     144  _Objects_Open(
     145    &_POSIX_Message_queue_Information_fds,
     146    &the_mq_fd->Object,
     147    NULL
     148  );
     149 
    127150  _Thread_Enable_dispatch();
    128151
    129   if ( status == -1 )
    130     return (mqd_t) -1;
    131  
    132   return (mqd_t) the_mq->Object.id;
     152  return (mqd_t) the_mq_fd->Object.id;
    133153}
    134154
  • c/src/exec/posix/src/mqueuerecvsupp.c

    re6ff222 r53092d1  
    4949)
    5050{
    51   register POSIX_Message_queue_Control *the_mq;
    52   Objects_Locations                     location;
    53   unsigned32                            length_out;
     51  POSIX_Message_queue_Control     *the_mq;
     52  POSIX_Message_queue_Control_fd  *the_mq_fd;
     53  Objects_Locations                location;
     54  unsigned32                       length_out;
    5455 
    55   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     56  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    5657  switch ( location ) {
    5758    case OBJECTS_ERROR:
     
    6263      rtems_set_errno_and_return_minus_one( EINVAL );
    6364    case OBJECTS_LOCAL:
    64       if ( (the_mq->oflag & O_ACCMODE) == O_WRONLY ) {
     65      if ( (the_mq_fd->oflag & O_ACCMODE) == O_WRONLY ) {
    6566        _Thread_Enable_dispatch();
    6667        rtems_set_errno_and_return_minus_one( EBADF );
    6768      }
     69
     70      the_mq = the_mq_fd->Queue;
    6871
    6972      if ( msg_len < the_mq->Message_queue.maximum_message_size ) {
     
    8487        msg_ptr,
    8588        &length_out,
    86         (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
     89        (the_mq_fd->oflag & O_NONBLOCK) ? FALSE : TRUE,
    8790        timeout
    8891      );
  • c/src/exec/posix/src/mqueuesendsupp.c

    re6ff222 r53092d1  
    4747)
    4848{
    49   register POSIX_Message_queue_Control *the_mq;
    50   Objects_Locations                     location;
    51   CORE_message_queue_Status             msg_status;
     49  POSIX_Message_queue_Control    *the_mq;
     50  POSIX_Message_queue_Control_fd *the_mq_fd;
     51  Objects_Locations               location;
     52  CORE_message_queue_Status       msg_status;
    5253
    5354  /*
     
    5960    rtems_set_errno_and_return_minus_one( EINVAL );
    6061
    61   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
    62 
     62  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    6363  switch ( location ) {
    6464    case OBJECTS_ERROR:
     
    7171
    7272    case OBJECTS_LOCAL:
    73       if ( (the_mq->oflag & O_ACCMODE) == O_RDONLY ) {
     73      if ( (the_mq_fd->oflag & O_ACCMODE) == O_RDONLY ) {
    7474        _Thread_Enable_dispatch();
    7575        rtems_set_errno_and_return_minus_one( EBADF );
    7676      }
     77
     78      the_mq = the_mq_fd->Queue;
    7779
    7880      msg_status = _CORE_message_queue_Submit(
     
    8789#endif
    8890        _POSIX_Message_queue_Priority_to_core( msg_prio ),
    89          (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
     91         (the_mq_fd->oflag & O_NONBLOCK) ? FALSE : TRUE,
    9092        timeout    /* no timeout */
    9193      );
  • c/src/exec/posix/src/mqueuesetattr.c

    re6ff222 r53092d1  
    4444)
    4545{
    46   register POSIX_Message_queue_Control *the_mq;
    47   CORE_message_queue_Control           *the_core_mq;
    48   Objects_Locations                     location;
    49   CORE_message_queue_Attributes        *the_mq_attr;
     46  POSIX_Message_queue_Control_fd *the_mq_fd;
     47  CORE_message_queue_Control     *the_core_mq;
     48  Objects_Locations               location;
    5049 
    5150  if ( !mqstat )
    5251    rtems_set_errno_and_return_minus_one( EINVAL );
    5352
    54   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     53  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    5554  switch ( location ) {
    5655    case OBJECTS_ERROR:
     
    6261    case OBJECTS_LOCAL:
    6362
    64       the_core_mq = &the_mq->Message_queue;
     63      the_core_mq = &the_mq_fd->Queue->Message_queue;
    6564
    6665      /*
     
    6867       */
    6968
    70       /* XXX this is the same stuff as is in mq_getattr... and probably */
    71       /* XXX should be in an inlined private routine */
    72 
    7369      if ( omqstat ) {
    74         omqstat->mq_flags   = the_mq->oflag;
     70        omqstat->mq_flags   = the_mq_fd->oflag;
    7571        omqstat->mq_msgsize = the_core_mq->maximum_message_size;
    7672        omqstat->mq_maxmsg  = the_core_mq->maximum_pending_messages;
    7773        omqstat->mq_curmsgs = the_core_mq->number_of_pending_messages;
    7874      }
    79  
    80       /*
    81        *  If blocking was in effect and is not now, then there
    82        *  may be threads blocked on this message queue which need
    83        *  to be unblocked to make the state of the message queue
    84        *  consistent for future use.
    85        */
    8675 
    87       the_mq_attr = &the_core_mq->Attributes;
    88 
    89       if ( !(the_mq->oflag & O_NONBLOCK) &&         /* were blocking */
    90            (mqstat->mq_flags & O_NONBLOCK) ) {      /* and now are not */
    91         _CORE_message_queue_Flush_waiting_threads( the_core_mq );
    92       }
    93      
    94       the_mq->oflag = mqstat->mq_flags;
    95 
     76      the_mq_fd->oflag = mqstat->mq_flags;
    9677      _Thread_Enable_dispatch();
    9778      return 0;
  • cpukit/posix/ChangeLog

    re6ff222 r53092d1  
     12001-04-26      Joel Sherrill <joel@OARcorp.com>
     2
     3        * include/rtems/posix/mqueue.h, inline/rtems/posix/mqueue.inl,
     4        src/mqueue.c, src/mqueueclose.c, src/mqueuecreatesupp.c,
     5        src/mqueuegetattr.c, src/mqueuenotify.c, src/mqueueopen.c,
     6        src/mqueuerecvsupp.c, src/mqueuesendsupp.c, src/mqueuesetattr.c:
     7        Per PR81 reworked to add a message queue descriptor separate from
     8        the underlying message queue.  This allows non-blocking to follow
     9        the "open" not the underlying queue.
     10 
    1112002-04-06      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    212
  • cpukit/posix/include/rtems/posix/mqueue.h

    re6ff222 r53092d1  
    3535   boolean                     named;
    3636   boolean                     linked;
    37    int                         oflag;
    3837   unsigned32                  open_count;
    3938   CORE_message_queue_Control  Message_queue;
     
    4140}  POSIX_Message_queue_Control;
    4241
     42typedef struct {
     43   Objects_Control              Object;
     44   POSIX_Message_queue_Control *Queue;
     45   int                          oflag;
     46} POSIX_Message_queue_Control_fd;
     47
    4348/*
    4449 *  The following defines the information control block used to manage
    45  *  this class of objects.
     50 *  this class of objects.  The second item is used to manage the set
     51 *  of "file descriptors" associated with the message queues.
    4652 */
    4753 
    4854POSIX_EXTERN Objects_Information  _POSIX_Message_queue_Information;
     55POSIX_EXTERN Objects_Information  _POSIX_Message_queue_Information_fds;
    4956 
    5057/*
     
    7380  const char                    *name,
    7481  int                            pshared,
    75   unsigned int                   oflag,
    7682  struct mq_attr                *attr,
    7783  POSIX_Message_queue_Control  **message_queue
     
    183189 *  DESCRIPTION:
    184190 *
    185  *  XXX
     191 *  This routine looks up the specified name for a message queue and returns the
     192 *  id of the message queue associated with it.
    186193 */
    187194
  • cpukit/posix/inline/rtems/posix/mqueue.inl

    re6ff222 r53092d1  
    2222 */
    2323 
    24 RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Allocate( void )
     24RTEMS_INLINE_ROUTINE
     25  POSIX_Message_queue_Control *_POSIX_Message_queue_Allocate( void )
    2526{
    2627  return (POSIX_Message_queue_Control *)
    2728    _Objects_Allocate( &_POSIX_Message_queue_Information );
     29}
     30 
     31/*PAGE
     32 *
     33 *  _POSIX_Message_queue_Allocate_fd
     34 */
     35 
     36RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *
     37  _POSIX_Message_queue_Allocate_fd( void )
     38{
     39  return (POSIX_Message_queue_Control_fd *)
     40    _Objects_Allocate( &_POSIX_Message_queue_Information_fds );
    2841}
    2942 
     
    3851{
    3952  _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object );
     53}
     54
     55/*PAGE
     56 *
     57 *  _POSIX_Message_queue_Free_fd
     58 */
     59 
     60RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free_fd (
     61  POSIX_Message_queue_Control_fd *the_mq_fd
     62)
     63{
     64  _Objects_Free( &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object );
    4065}
    4166
     
    6590  return (POSIX_Message_queue_Control *)
    6691    _Objects_Get( &_POSIX_Message_queue_Information, id, location );
     92}
     93 
     94/*PAGE
     95 *
     96 *  _POSIX_Message_queue_Get_fd
     97 */
     98 
     99RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *_POSIX_Message_queue_Get_fd (
     100  Objects_Id         id,
     101  Objects_Locations *location
     102)
     103{
     104  return (POSIX_Message_queue_Control_fd *)
     105    _Objects_Get( &_POSIX_Message_queue_Information_fds, id, location );
    67106}
    68107 
  • cpukit/posix/src/mqueue.c

    re6ff222 r53092d1  
    5959    FALSE
    6060  );
     61  _Objects_Initialize_information(
     62    &_POSIX_Message_queue_Information_fds,
     63    OBJECTS_POSIX_MESSAGE_QUEUE_FDS,
     64    FALSE,
     65    maximum_message_queues,
     66    sizeof( POSIX_Message_queue_Control_fd ),
     67    FALSE,
     68    0,
     69    FALSE
     70  );
    6171}
  • cpukit/posix/src/mqueueclose.c

    re6ff222 r53092d1  
    4242)
    4343{
    44   register POSIX_Message_queue_Control *the_mq;
    45   Objects_Locations                     location;
     44  POSIX_Message_queue_Control    *the_mq;
     45  POSIX_Message_queue_Control_fd *the_mq_fd;
     46  Objects_Locations               location;
    4647 
    47   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     48  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    4849  switch ( location ) {
    4950    case OBJECTS_ERROR:
     
    5455      rtems_set_errno_and_return_minus_one( EINVAL );
    5556    case OBJECTS_LOCAL:
     57      /*
     58       *  First update the actual message queue to reflect this descriptor
     59       *  being disassociated.  This may result in the queue being really
     60       *  deleted.
     61       */
     62
     63      the_mq = the_mq_fd->Queue;
    5664      the_mq->open_count -= 1;
    5765      _POSIX_Message_queue_Delete( the_mq );
     66
     67      /*
     68       *  Now close this file descriptor.
     69       */
     70
     71      _Objects_Close(
     72        &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object );
     73      _POSIX_Message_queue_Free_fd( the_mq_fd );
     74
    5875      _Thread_Enable_dispatch();
    5976      return 0;
  • cpukit/posix/src/mqueuecreatesupp.c

    re6ff222 r53092d1  
    4242 
    4343int _POSIX_Message_queue_Create_support(
    44   const char                    *name,
     44  const char                    *_name,
    4545  int                            pshared,
    46   unsigned int                   oflag,
    4746  struct mq_attr                *attr_ptr,
    4847  POSIX_Message_queue_Control  **message_queue
     
    5251  CORE_message_queue_Attributes *the_mq_attr;
    5352  struct mq_attr                 attr;
     53  char *name;
    5454
    5555  _Thread_Disable_dispatch();
     
    9696 
    9797  the_mq->process_shared  = pshared;
    98   the_mq->oflag = oflag;
    9998  the_mq->named = TRUE;
    10099  the_mq->open_count = 1;
     
    134133  }
    135134
     135  name = malloc(256);
     136  strcpy( name, _name );
    136137  _Objects_Open(
    137138    &_POSIX_Message_queue_Information,
  • cpukit/posix/src/mqueuegetattr.c

    re6ff222 r53092d1  
    4343)
    4444{
    45   register POSIX_Message_queue_Control *the_mq;
     45  POSIX_Message_queue_Control          *the_mq;
     46  POSIX_Message_queue_Control_fd       *the_mq_fd;
    4647  Objects_Locations                     location;
    4748  CORE_message_queue_Attributes        *the_mq_attr;
     
    5051    rtems_set_errno_and_return_minus_one( EINVAL );
    5152
    52   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     53  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    5354  switch ( location ) {
    5455    case OBJECTS_ERROR:
     
    5960      rtems_set_errno_and_return_minus_one( EINVAL );
    6061    case OBJECTS_LOCAL:
     62      the_mq = the_mq_fd->Queue;
     63
    6164      /*
    6265       *  Return the old values.
    6366       */
    6467 
    65       /* XXX this is the same stuff as is in mq_setattr... and probably */
    66       /* XXX should be in an inlined private routine */
    67  
    6868      the_mq_attr = &the_mq->Message_queue.Attributes;
    6969 
    70       mqstat->mq_flags   = the_mq->oflag;
     70      mqstat->mq_flags   = the_mq_fd->oflag;
    7171      mqstat->mq_msgsize = the_mq->Message_queue.maximum_message_size;
    7272      mqstat->mq_maxmsg  = the_mq->Message_queue.maximum_pending_messages;
  • cpukit/posix/src/mqueuenotify.c

    re6ff222 r53092d1  
    6565)
    6666{
    67   register POSIX_Message_queue_Control *the_mq;
    68   Objects_Locations                     location;
     67  POSIX_Message_queue_Control    *the_mq;
     68  POSIX_Message_queue_Control_fd *the_mq_fd;
     69  Objects_Locations               location;
    6970 
    70   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     71  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    7172  switch ( location ) {
    7273    case OBJECTS_ERROR:
     
    7778      rtems_set_errno_and_return_minus_one( EINVAL );
    7879    case OBJECTS_LOCAL:
     80      the_mq = the_mq_fd->Queue;
     81
    7982      if ( notification ) {
    8083        if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
  • cpukit/posix/src/mqueueopen.c

    re6ff222 r53092d1  
    4646)
    4747{
    48   va_list                        arg;
    49   mode_t                         mode;
    50   struct mq_attr                *attr = NULL;
    51   int                            status;
    52   Objects_Id                     the_mq_id;
    53   POSIX_Message_queue_Control   *the_mq;
    54   Objects_Locations              location;
     48  va_list                         arg;
     49  mode_t                          mode;
     50  struct mq_attr                 *attr = NULL;
     51  int                             status;
     52  Objects_Id                      the_mq_id;
     53  POSIX_Message_queue_Control    *the_mq;
     54  POSIX_Message_queue_Control_fd *the_mq_fd;
     55  Objects_Locations               location;
    5556 
    5657  _Thread_Disable_dispatch();
     
    6364  }
    6465 
     66  the_mq_fd = _POSIX_Message_queue_Allocate_fd();
     67  if ( !the_mq_fd ) {
     68    _Thread_Enable_dispatch();
     69    rtems_set_errno_and_return_minus_one( ENFILE );
     70  }
     71  the_mq_fd->oflag = oflag;
     72
    6573  status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
    66  
     74
    6775  /*
    6876   *  If the name to id translation worked, then the message queue exists
     
    8088
    8189    if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
     90      _POSIX_Message_queue_Free_fd( the_mq_fd );
    8291      _Thread_Enable_dispatch();
    8392      rtems_set_errno_and_return_minus_one_cast( status, mqd_t );
     
    91100
    92101    if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
     102      _POSIX_Message_queue_Free_fd( the_mq_fd );
    93103      _Thread_Enable_dispatch();
    94104      rtems_set_errno_and_return_minus_one_cast( EEXIST, mqd_t );
     
    96106
    97107    /*
    98      * XXX In this case we need to do an ID->pointer conversion to
    99      *     check the mode.   This is probably a good place for a subroutine.
     108     * In this case we need to do an ID->pointer conversion to
     109     * check the mode.
    100110     */
    101111
    102112    the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
    103113    the_mq->open_count += 1;
     114    the_mq_fd->Queue = the_mq;
    104115    _Thread_Enable_dispatch();
    105116    _Thread_Enable_dispatch();
    106     return (mqd_t)the_mq->Object.id;
     117    return (mqd_t)the_mq_fd->Object.id;
    107118 
    108119  }
     
    116127    name,
    117128    TRUE,         /* shared across processes */
    118     oflag,
    119129    attr,
    120130    &the_mq
     
    125135   */
    126136
     137  if ( status == -1 ) {
     138    _Thread_Enable_dispatch();
     139    _POSIX_Message_queue_Free_fd( the_mq_fd );
     140    return (mqd_t) -1;
     141  }
     142 
     143  the_mq_fd->Queue = the_mq;
     144  _Objects_Open(
     145    &_POSIX_Message_queue_Information_fds,
     146    &the_mq_fd->Object,
     147    NULL
     148  );
     149 
    127150  _Thread_Enable_dispatch();
    128151
    129   if ( status == -1 )
    130     return (mqd_t) -1;
    131  
    132   return (mqd_t) the_mq->Object.id;
     152  return (mqd_t) the_mq_fd->Object.id;
    133153}
    134154
  • cpukit/posix/src/mqueuerecvsupp.c

    re6ff222 r53092d1  
    4949)
    5050{
    51   register POSIX_Message_queue_Control *the_mq;
    52   Objects_Locations                     location;
    53   unsigned32                            length_out;
     51  POSIX_Message_queue_Control     *the_mq;
     52  POSIX_Message_queue_Control_fd  *the_mq_fd;
     53  Objects_Locations                location;
     54  unsigned32                       length_out;
    5455 
    55   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     56  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    5657  switch ( location ) {
    5758    case OBJECTS_ERROR:
     
    6263      rtems_set_errno_and_return_minus_one( EINVAL );
    6364    case OBJECTS_LOCAL:
    64       if ( (the_mq->oflag & O_ACCMODE) == O_WRONLY ) {
     65      if ( (the_mq_fd->oflag & O_ACCMODE) == O_WRONLY ) {
    6566        _Thread_Enable_dispatch();
    6667        rtems_set_errno_and_return_minus_one( EBADF );
    6768      }
     69
     70      the_mq = the_mq_fd->Queue;
    6871
    6972      if ( msg_len < the_mq->Message_queue.maximum_message_size ) {
     
    8487        msg_ptr,
    8588        &length_out,
    86         (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
     89        (the_mq_fd->oflag & O_NONBLOCK) ? FALSE : TRUE,
    8790        timeout
    8891      );
  • cpukit/posix/src/mqueuesendsupp.c

    re6ff222 r53092d1  
    4747)
    4848{
    49   register POSIX_Message_queue_Control *the_mq;
    50   Objects_Locations                     location;
    51   CORE_message_queue_Status             msg_status;
     49  POSIX_Message_queue_Control    *the_mq;
     50  POSIX_Message_queue_Control_fd *the_mq_fd;
     51  Objects_Locations               location;
     52  CORE_message_queue_Status       msg_status;
    5253
    5354  /*
     
    5960    rtems_set_errno_and_return_minus_one( EINVAL );
    6061
    61   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
    62 
     62  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    6363  switch ( location ) {
    6464    case OBJECTS_ERROR:
     
    7171
    7272    case OBJECTS_LOCAL:
    73       if ( (the_mq->oflag & O_ACCMODE) == O_RDONLY ) {
     73      if ( (the_mq_fd->oflag & O_ACCMODE) == O_RDONLY ) {
    7474        _Thread_Enable_dispatch();
    7575        rtems_set_errno_and_return_minus_one( EBADF );
    7676      }
     77
     78      the_mq = the_mq_fd->Queue;
    7779
    7880      msg_status = _CORE_message_queue_Submit(
     
    8789#endif
    8890        _POSIX_Message_queue_Priority_to_core( msg_prio ),
    89          (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
     91         (the_mq_fd->oflag & O_NONBLOCK) ? FALSE : TRUE,
    9092        timeout    /* no timeout */
    9193      );
  • cpukit/posix/src/mqueuesetattr.c

    re6ff222 r53092d1  
    4444)
    4545{
    46   register POSIX_Message_queue_Control *the_mq;
    47   CORE_message_queue_Control           *the_core_mq;
    48   Objects_Locations                     location;
    49   CORE_message_queue_Attributes        *the_mq_attr;
     46  POSIX_Message_queue_Control_fd *the_mq_fd;
     47  CORE_message_queue_Control     *the_core_mq;
     48  Objects_Locations               location;
    5049 
    5150  if ( !mqstat )
    5251    rtems_set_errno_and_return_minus_one( EINVAL );
    5352
    54   the_mq = _POSIX_Message_queue_Get( mqdes, &location );
     53  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
    5554  switch ( location ) {
    5655    case OBJECTS_ERROR:
     
    6261    case OBJECTS_LOCAL:
    6362
    64       the_core_mq = &the_mq->Message_queue;
     63      the_core_mq = &the_mq_fd->Queue->Message_queue;
    6564
    6665      /*
     
    6867       */
    6968
    70       /* XXX this is the same stuff as is in mq_getattr... and probably */
    71       /* XXX should be in an inlined private routine */
    72 
    7369      if ( omqstat ) {
    74         omqstat->mq_flags   = the_mq->oflag;
     70        omqstat->mq_flags   = the_mq_fd->oflag;
    7571        omqstat->mq_msgsize = the_core_mq->maximum_message_size;
    7672        omqstat->mq_maxmsg  = the_core_mq->maximum_pending_messages;
    7773        omqstat->mq_curmsgs = the_core_mq->number_of_pending_messages;
    7874      }
    79  
    80       /*
    81        *  If blocking was in effect and is not now, then there
    82        *  may be threads blocked on this message queue which need
    83        *  to be unblocked to make the state of the message queue
    84        *  consistent for future use.
    85        */
    8675 
    87       the_mq_attr = &the_core_mq->Attributes;
    88 
    89       if ( !(the_mq->oflag & O_NONBLOCK) &&         /* were blocking */
    90            (mqstat->mq_flags & O_NONBLOCK) ) {      /* and now are not */
    91         _CORE_message_queue_Flush_waiting_threads( the_core_mq );
    92       }
    93      
    94       the_mq->oflag = mqstat->mq_flags;
    95 
     76      the_mq_fd->oflag = mqstat->mq_flags;
    9677      _Thread_Enable_dispatch();
    9778      return 0;
Note: See TracChangeset for help on using the changeset viewer.