There's bug occurs in my project, and I found that it could be the large message passing by the windows namedpipe.
The process1 produce about 80 KB message, and I have a namepdpipe attach to its standard output.
After the process 2 read the message from the namedpipe, I found the message is incomplete.
The pseudo code is like that,
char buffer[4096] ;
string msg ;
while( !namedpipe.isEmpty() ) {
int length = namedPipe.read(buffer, 4096) ;
msg.append(buffer, length) ;
}
After google some information about the namedpipe, I found the namedpipe is limit in 65535 byte.
The 80KB message would exceed the limit.
But when I insert the Sleep(1000) before the read.
char buffer[4096] ;
string msg ;
while( !namedpipe.isEmpty() ) {
Sleep(1000) ;
int length = namedPipe.read(buffer, 4096) ;
msg.append(buffer, length) ;
}
The message is OK and complete.
I think that in the sleeping moment, system requests the memory for the namedpipe.
So the namedpipe would only ensure 65535 byte to use.
Is the progress that I infered correct?