For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > September 2005 > Messages never read from message queue !!!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Messages never read from message queue !!!
mderie

2005-09-30, 6:59 pm

Hi !

I'm facing a very strange behaviour using message queues on Linux
(and sorry not on unix...) :

My two processes let say P1 & P2 are child of the "main" process a
viewer V...
P1 sends six messages, the ID's are 3, 2, 1, 5, 4 & 6
And P2 gets 3, 2, 1 & 5 ... The two last are lost !
Well not really because when I launch a "ipcs" I see them in the queue
!
So why (the hell) the P2 doesn't read them ?

Thanks a lot in advance

Pascal Bourguignon

2005-09-30, 6:59 pm

"mderie" <mderie@gmail.com> writes:

> Hi !
>
> I'm facing a very strange behaviour using message queues on Linux
> (and sorry not on unix...) :
>
> My two processes let say P1 & P2 are child of the "main" process a
> viewer V...
> P1 sends six messages, the ID's are 3, 2, 1, 5, 4 & 6
> And P2 gets 3, 2, 1 & 5 ... The two last are lost !
> Well not really because when I launch a "ipcs" I see them in the queue
> !
> So why (the hell) the P2 doesn't read them ?
>
> Thanks a lot in advance


Without more data (like your sources), we can only advice you to read
again the man page msgrcv(2) :

The argument msgsz specifies the maximum size in bytes for the
member mtext of the structure pointed to by the msgp argument.
If the message text has length greater than msgsz, then if the
msgflg argument asserts MSG_NOERROR, the message text will be
truncated (and the truncated part will be lost), otherwise the
message isn't removed from the queue and the system call fails
returning with errno set to E2BIG.

The argument msgtyp specifies the type of message requested as
follows:

If msgtyp is 0, then the first message in the queue is
read.

If msgtyp is greater than 0, then the first message on the
queue of type msgtyp is read, unless MSG_EXCEPT was
asserted in msgflg, in which case the first message on the
queue of type not equal to msgtyp will be read.

If msgtyp is less than 0, then the first message on the
queue with the lowest type less than or equal to the abso_
lute value of msgtyp will be read.

The msgflg argument asserts none, one or more (or-ing them) of
the following flags:

IPC_NOWAIT For immediate return if no message of the
requested type is on the queue. The system call fails
with errno set to ENOMSG.

MSG_EXCEPT Used with msgtyp greater than 0 to read the
first message on the queue with message type that differs
from msgtyp.

MSG_NOERROR To truncate the message text if longer than
msgsz bytes.

If no message of the requested type is available and IPC_NOWAIT
isn't asserted in msgflg, the calling process is blocked until
one of the following conditions occurs:

A message of the desired type is placed on the queue.

The message queue is removed from the system. In this
case the system call fails with errno set to EIDRM.

The calling process catches a signal. In this case the
system call fails with errno set to EINTR.

Upon successful completion the message queue data structure is
updated as follows:

msg_lrpid is set to the process ID of the calling process.

msg_qnum is decremented by 1.

msg_rtime is set to the current time.


--
__Pascal Bourguignon__ http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com