RTEMS | Need to invalidate posix message queue object id when delete mq (!364)
Joel Sherrill (@joel)
gitlab at rtems.org
Wed May 21 16:47:42 UTC 2025
Joel Sherrill commented on a discussion on testsuites/psxtests/psxmsgq01/init.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/364#note_122731
> fatal_posix_service_status( status, 0, "mq_close duplicate message queue");
> status = mq_close( Test_q[CLOSED].mq );
> fatal_posix_service_status( status, 0, "mq_close message queue");
> + /*
> + * EBADF - Close a queue that is already closed.
> + */
> + status = mq_close( Test_q[CLOSED].mq );
> + fatal_posix_service_status( status, -1, "mq_close error return status");
> + fatal_posix_service_status( errno, EBADF, "mq_close errno EBADF");
I think the change is correct because it is invalidating the id passed in to mq_close(). The test changes are likely ok but not exercising what changed fully. This use case may require a different approach with multiple calls. mq_unlink() takes the mq out of the namespace. You cannot mq_open() it again but all mq descriptors from previous opens on the same mq are valid until all are closed. How about something like this:
+ mq_open
+ mq_unlink
+ mq_open again -> should fail.
+ mq_close -> OK, should delete since no uses
+ mq_close -> should fail, mq id is now invalid
The second mq_open is what verifies the mq name is gone. The first mq_close() working says the id is ok. The second says the id is no longer OK.
mq_getattr() is a call which could be used to verify if an id is valid or not.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/364#note_122731
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250521/5094f712/attachment.htm>
More information about the bugs
mailing list