This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: Message queue support
Patch checked in. Thanks.
-- Jeff J.
Jose Miguel Goncalves wrote:
OK Jeff, I agree with you.
José Gonçalves
J. Johnston wrote:
Thanks Jose,
The first part regarding the "created" flag is correct, however, I
do not agree
with the 2nd part of your change. That code ensures that the creator
of the shared memory file also
owns the semaphores. Once the "created" flag has been set correctly,
it should work for
your test.
-- Jeff J.
Jose Miguel Goncalves wrote:
Jeff,
I have found another bug in mq_open(). When called more than once
(for the same queue) with O_CREAT flag set, it fails. Sugested patch:
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/linux/mq_open.c,v
retrieving revision 1.3
diff -p -u -r1.3 mq_open.c
--- mq_open.c 27 Jun 2003 00:00:48 -0000 1.3
+++ mq_open.c 27 Jun 2003 14:53:04 -0000
@@ -98,7 +98,8 @@ mq_open (const char *name, int oflag, ..
return (mqd_t)-1;
}
errno = saved_errno;
- created = 1;
+ if (fd >= 0)
+ created = 1;
}
if (fd < 0)
@@ -132,9 +133,12 @@ mq_open (const char *name, int oflag, ..
saved_errno = errno;
semid = semget (key, 6, IPC_CREAT | IPC_EXCL | mode);
errno = saved_errno;
- /* now that we have created the semaphore, we should
initialize it */
if (semid != -1)
+ /* now that we have created the semaphore, we should
initialize it */
semctl (semid, 0, SETVAL, arg);
+ else
+ /* semaphore already exists, so we get only it's id */
+ semid = semget (key, 6, 0);
}
else
{
Regards,
José Gonçalves
J. Johnston wrote:
Jose,
I found a serious problem with opening an existing queue for read
whereby the
read/write buffers were not being allocated. A patch has been
committed to the
sources. With that patch applied I was able to run your test case
successfully.
-- Jeff J.
Jose Miguel Goncalves wrote:
Jeff,
After setting up /dev/shm I could create a queue with mq_open(),
and send messages with mq_send(), but calling to mq_receive()
returns errors - "Bad address".
I attach the source code for the simple mqueue test application
that I'm using. I am compiling in a 2.4.21 linux kernel with:
$ gcc -static -nostdlib -g -Wall -D_REENTRANT
-I/usr/local/newlib/i686-pc-linux-gnu/include
/usr/local/newlib/i686-pc-linux-gnu/lib/crt0.o test_thread_queue.c
-L/usr/local/newlib/i686-pc-linux-gnu/lib -lpthread -lc -lgcc -o
test_thread_queue
The same source compiled in a Sun Solaris 8 machine (with native
support for pthreads and mqueues) works fine.
Regards,
José Gonçalves