开发者

Making message queues non-persistent in Linux

This may be a completely newbie question about message Queues, but we are havi开发者_Go百科ng some issues with them being persistent across the Linux system. We are running Fedora 14 and using message queues to pass data to and from threads.

The problem is we create a message queue:

q = mq_open (strName, O_RDWR | O_CREAT | O_NONBLOCK, 0666, &sQAttr)

where:

strName = "/INFO_UPD_Q" or "/POLL_Q" ...
sQAttr.mq_flags   = 0;
sQAttr.mq_maxmsg  = iMaxNumMessages; /* 1 - 10 */
sQAttr.mq_msgsize = iSzOfMessages;
sQAttr.mq_curmsgs = 0;

The issue we are having is that as soon as we change the size of the messages passed or the app crashes/exits/aborts and the queues have not been closed and emptied, the next run of the programme floods the system with old messages or does not open correctly and data does not get to the threads.

At the moment we are solving the issue by changing the name of queues and then rebooting the system every so often.

How do we get the queues to stop doing this?

Thanks.


From the shell you can see all the existing queues using:

# ipcs -q

And you can remove stale queues:

# ipcrm -q MSQID

The MSQID is available from the output of the first command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜