msgrcv() in a g_timeout handler?



I have a situation where there are several backend processes that push
small messages in to sysvipc message queues, using msgsnd().  I need to
pick up these messages in my frontend (gtk+) process and change some
status indicators on the display.

What I've done is add a timeout handler via g_timeout_add that calls
msgrcv() each time it wakes up to see if there is a message waiting on one
of the message queues.  If there is, it reads the message and makes a few
gtk calls to update the screen.  At that point it calls msgrcv() on the a
second message queue, and again makes a few gtk calls if it gets a
message.

I have the handler wrapped in gdk_threads_enter() and gdk_threads_leave(),
since I'm making gtk/gdk calls fron the handler.

My problem is that, sometimes, messages go in to the queue, but don't show
up at the other end.  It feels like a race condition issue to me, but I
can't track it down, and any small test example I put together works fine.
 The only place I can replicate the problem is in my full app, all the
process running, etc.   Figures....

Has anybody done something like this between different processes across
sysvipc message queues, and gotten it to work?  Anyone got suggestions for
a different approach?

Thanks,
Al





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]