diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2002-04-26 23:39:01 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2002-04-26 23:39:01 +0000 |
commit | 53092d19211054d67787990714798c2e72c8a623 (patch) | |
tree | 9386e2095e8fd1d9c3e419faae2006df2ec80a48 /cpukit/posix/src/mqueueclose.c | |
parent | 2001-04-26 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-53092d19211054d67787990714798c2e72c8a623.tar.bz2 |
2001-04-26 Joel Sherrill <joel@OARcorp.com>
* 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.
Diffstat (limited to '')
-rw-r--r-- | cpukit/posix/src/mqueueclose.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/cpukit/posix/src/mqueueclose.c b/cpukit/posix/src/mqueueclose.c index 80da647116..e809eac3ec 100644 --- a/cpukit/posix/src/mqueueclose.c +++ b/cpukit/posix/src/mqueueclose.c @@ -41,10 +41,11 @@ int mq_close( mqd_t mqdes ) { - register POSIX_Message_queue_Control *the_mq; - Objects_Locations location; + POSIX_Message_queue_Control *the_mq; + POSIX_Message_queue_Control_fd *the_mq_fd; + Objects_Locations location; - the_mq = _POSIX_Message_queue_Get( mqdes, &location ); + the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location ); switch ( location ) { case OBJECTS_ERROR: rtems_set_errno_and_return_minus_one( EBADF ); @@ -53,8 +54,24 @@ int mq_close( return POSIX_MP_NOT_IMPLEMENTED(); rtems_set_errno_and_return_minus_one( EINVAL ); case 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; } |