Question

I'm having a problem with creating mqueues, namely my system appears to block me from creating more than 5 mqueues, even though /proc/sys/fs/mqueue/queues_max is set to 256. I'm running Ubuntu 13.04 server on an a Q7 module system with a Atom E680T, I'm also running a custom compiled kernel (3.8.0) to reduce the kernel size and to add watchdog and i2c access that was missing from the default.

I've checked to make sure that only 5 mqueues are being used by mounting the mqueue interface, after 5 have been created it won't let me create a 6th, returning a "Too many open files." error. To make sure there was nothing wrong with the function call I deleted one of the existing queues and ran my program again and it successfully created the queue.

I'm currently at a loss, the information I can find indicates that /proc/sys/fs/mqueue/queues_max should control the limit, and that defaults to 256. But modifiying this or any other file in that folder doesn't appeart to help.

So if anyone can point me in the right direction as to where this limit could be I would be grateful, for the most part the mqueues are being created with variations of this:

    mq_attr attribs;
//initialise the incoming message queue.
printLog ("I2C MANAGER: Registering mqueue.\n");
// Set attributes for main message queue
attribs.mq_maxmsg = 512;
attribs.mq_msgsize = sizeof(t_io_message);
attribs.mq_flags=0;
// Create the queue
in_queue = mq_open(I2C_MQUEUE, O_RDONLY|O_CREAT, 0666, &attribs);
// Check queue was successfully created
if (-1 == in_queue)
{
    printLogf ("I2C MANAGER: Error unable to register mqueue /i2c-manager: %s.\n", strerror(errno));
    exit(1);
}
else
{
    printLog ("I2C MANAGER: Mqueue Initialisation succesfull.\n");
}
Was it helpful?

Solution

I worked it out, the error message was misleading, it wasn't that I had too many mqueues open, it was that the mqueues had allocated for these-selves most of the memory assigned to the mqueue system. So when I tried to open a new mqueue it couldn't get enough memory for it and failed to open.

Looking at the code for the other processes I should be able to free up the space by just reducing the maxmsg value. Some are using queue sizes of 1000, the one above I copy pasted from another process is set to 512 messages, which seems very excessive. Did a quick test by halving that value in two processes and now I have my 6th queue running.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top