InterprocessConnection loose messages


#1

Hi,

I'am writing a dameon using pipe for interprocess communication.

When i receive a message from a client, i do some logging.
When i send 2 or more messages to the daemon, the interprocessConnection class seems to only receive the first one : the others messages are lost.
If I do some sleeping beetwen my message sending, all of them are correctly received.
I tried to change InterprocesConnection callback ( message or server thread ) but i still have the same issue.

Any idea ?

Denis.


#2

Hi,

I'am still wondering why messages are lost.

By the way, while looking at JUCE source code for InterprocessConnection, i think i’ve spotted a little mistake.

in InterprocessConnection::readNextMessageInt()

 while (bytesRead < bytesInMessage)
            {
                if (threadShouldExit())
                    return false;

                const int numThisTime = jmin (bytesInMessage, 65536);
                const int bytesIn = (socket != 0) ? socket->read (((char*) messageData.getData()) + bytesRead, numThisTime, true)
                                                  : pipe->read (((char*) messageData.getData()) + bytesRead, numThisTime,
                                                                pipeReceiveMessageTimeout);

                if (bytesIn <= 0)
                    break;

                bytesRead += bytesIn;
            }

I think that NumThisTime sould be : jmin (bytesInMessage - bytesRead, 65536);

Denis.


#3

Yes, good catch! Many thanks for that!


#4

And nothing to say about loose, Jules? You must be mellowing.


#5

Hehe, that was my first thought when I saw the thread title :wink:


#6

I came close to loosing my temper when I saw it, but managed to stay calm…