Index: sys/kern/sysv_msg.c =================================================================== RCS file: /cvs/src/sys/kern/sysv_msg.c,v retrieving revision 1.24 diff -u -r1.24 sysv_msg.c --- sys/kern/sysv_msg.c 20 May 2011 16:06:25 -0000 1.24 +++ sys/kern/sysv_msg.c 3 Feb 2012 23:58:45 -0000 @@ -230,7 +230,7 @@ goto again;
found: - *retval = que->que_id; + *retval = IXSEQ_TO_IPCID(0, que->msqid_ds.msg_perm); return (error); } @@ -421,7 +421,7 @@ struct que *que; TAILQ_FOREACH(que, &msg_queues, que_next) - if (que->que_id == id) + if (que->msqid_ds.msg_perm.seq == IPCID_TO_SEQ(id)) break; /* don't return queues marked for removal */ Index: sys/sys/msg.h =================================================================== RCS file: /cvs/src/sys/sys/msg.h,v retrieving revision 1.16 diff -u -r1.16 msg.h --- sys/sys/msg.h 3 Jan 2011 23:08:07 -0000 1.16 +++ sys/sys/msg.h 3 Feb 2012 23:58:45 -0000 @@ -62,7 +62,6 @@ struct que { struct msqid_ds msqid_ds; - int que_id; int que_flags; int que_references; que_id was read to return msgq ids and to search for active msgqs but was never set. msgqid_ds.msg_perm.seq was set but was only read by user space programs. Result: only 1 msg queue could be used because queue id 0 was the only one returned and 0 matched the first queue. Note: while 32767 semaphore sets, message queues, and SYSV shared memory segments are probably enough for 5 or 10 years, the use of 0x7FFF, etc. as masks is ugly. The sysv code is slightly inconsistent in that some use an array for state and some use tailq. RBtree could be used instead. I'd be glad to change this but I'm really more concerned with getting very high performance for an application that's due for a demo next week.