Hi everyone, Hi Jules,
I found a bug in the InterprocessConnection class : when I try to connect to a pipe that was not created by another process, InterprocessConnection::connectToPipe returns TRUE.
I looked at the source code. Here are the functions called :
bool InterprocessConnection::connectToPipe (const String& pipeName, const int timeoutMs)
{
disconnect();
ScopedPointer<NamedPipe> newPipe (new NamedPipe());
if (newPipe->openExisting (pipeName)) // ==> openExisting will ALWAYS return TRUE (see below)
{
const ScopedLock sl (pipeAndSocketLock);
pipeReceiveMessageTimeout = timeoutMs;
initialiseWithPipe (newPipe.release());
return true; // ==> the function will always return TRUE
}
return false;
}
bool NamedPipe::openExisting (const String& pipeName)
{
close();
ScopedWriteLock sl (lock);
currentPipeName = pipeName;
return openInternal (pipeName, false); // ==> openInternal, with false as second arg, will ALWAYS return TRUE (see below)
}
bool NamedPipe::openInternal (const String& pipeName, const bool createPipe) // ==> createPipe is FALSE
{
pimpl = new Pimpl (pipeName, createPipe);
if (createPipe && pimpl->pipeH == INVALID_HANDLE_VALUE) // ==> first condition is FALSE, never enter the IF bloc...
{
pimpl = nullptr;
return false;
}
return true; // ==> ALWAYS return TRUE when createPipe is FALSE
}
I'd really like to rely on InterprocessConnection::connectToPipe's return value to handle connection errors.
Thanks in advance !
Gilles