R – mq_unlink setting errno to EEXIST

cmessage-queueposixsolaris

I'm using message queues for inter-thread communication in a server. The server was functioning as expected on Thursday evening. When I picked the project back up on Monday, it was unable to create two of the six queues in use, citing that they were already open (O_EXCL is set). This should not have been the case, but nevertheless I added an mq_unlink call with error checking and removed the O_EXCL flag from mq_open.

When I compiled and ran, the errno was set to EEXIST by both mq_unlink and mq_open. This should be a can't happen: mq_unlink can't set errno to EEXIST under any circumstances, and mq_open can only set EEXIST when the O_EXCL flag is set.

Any ideas why this is happening?

Best Answer

I believe that this is a Solaris bug. Check for a lock file (usually /var/tmp/.MQL/...) and remove it if you know the message queue is not in use. That should allow the unlink to succeed.

Related Topic