Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pankaj.acs

macrumors newbie
Original poster
Oct 5, 2010
2
0
Hello all,

We have a application where two processes communicate via IPC.
We are currently using Message Queue for this communication.

The problem that we are facing is that the Max message that we are able to send through Message Q is only 2048 bytes! :(

As soon as we send data more than 2048 bytes, msgsend returns -1 with error code: 22 [Invalid arguments].

We tried increasing the Message Q size using msgctl system call, but to no avail.
Even though msgctl for msgsize > 2048 returns success, the message Q size remains 2048 only.

Sample program that i wrote to increase the Message Q size is as follows:

**********************************************
msgid = msgget((key_t)1234, 0666 | IPC_CREAT);
if(-1==msgctl(msgid,IPC_STAT,&queue_ds))
{
printf("\nFailure in msgctl() 1");
}

printf("Queue size: %d", (int) queue_ds.msg_qbytes);

/* Increase Queue size */
queue_ds.msg_qbytes = 5000;

if(-1==msgctl(msgid,IPC_SET,&queue_ds))
{
printf("\nFailure in msgctl()");
}
else
{
printf("Queue size updated to: %d", (int) queue_ds.msg_qbytes);
}

if(-1==msgctl(msgid,IPC_STAT,&queue_ds))
{
printf("\nFailure in msgctl() 2");
}
printf("Modified Queue size: %d", (int) queue_ds.msg_qbytes);

*************************************************

Output:
Queue size: 2048
Queue size updated to: 5000
Modified Queue size: 2048

Any idea why we are not able to increase the Message Q size?
Is this a limitation on Mac OS X?

Appreciate any help/pointers in this regard.

Cheers!
 
Message Queue limit for MAC OS X

Yes, i executed the msgctl using super-user only.
Otherwise, I believe msgctl would have failed.

However, am eager to know if anyone has actually tried changing the Message Q size in Mac OS X?
I mean, is it even possible without recompiling the kernel.
 
Post complete compilable runnable code, not just a code fragment.

Why are you using msgq at all? My impression is that it's not designed or intended for large amounts of data. If you have multiple processes, especially unprivileged ones, sending large amounts of data, you're better off using either Unix-domain sockets or IP-domain sockets confined to localhost (the lo0 loopback interface).
 
you can use sysctl command to do the work.
msgctl can NOT modify fields other than mode/uid/gid/qbytes,
and if you want increase qbytes of queue, there is a top value limited by system,
so you have to use sysctl...
 
Threads like this one sure would be nice to know if there was a resolve. I'm left with a cliffhanger on this one!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.