Re: sysv_msg queue id error

2012-02-04 Thread Philip Guenther
On Fri, Feb 3, 2012 at 4:08 PM, Geoff Steckel g...@oat.com wrote:
...
 Result: only 1 msg queue could be used because queue id 0 was the
 only one returned and 0 matched the first queue.

Yeah, this was reported back on Jan 20th by Alexis Fouilhe; c.f. the
message with subject Message queue identifiers are broken.
blambert@ should be committing the fix soon.


Philip Guenther



sysv_msg queue id error

2012-02-03 Thread Geoff Steckel

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.c20 May 2011 16:06:25 -1.24
+++ sys/kern/sysv_msg.c3 Feb 2012 23:58:45 -
@@ -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.h3 Jan 2011 23:08:07 -1.16
+++ sys/sys/msg.h3 Feb 2012 23:58:45 -
@@ -62,7 +62,6 @@

 struct que {
 struct msqid_dsmsqid_ds;
-intque_id;
 intque_flags;
 intque_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.