Weird random API failure

Our app calls GetNamedPipeInfo() with successful results 99% of the time.
However, under stressful conditions I’ve witnessed the random failure
(GetLastError() == ERROR_INVALID_PARAMETER) of this API. All previous calls
using the pipe handle are successful (with good error checking). Re-calling
the API results in success, so we simply put the call in the loop. I’m
letting y’all know it here just in case you see this behavior occurring in
your app too. The calling sequence:

hPipe = ::CreateFile(szRemotePipeName,
GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH |
FILE_FLAG_OVERLAPPED, NULL)) != INVALID_HANDLE_VALUE);

if(hPipe == INVALID_HANDLE_VALUE) {
(error reporting)
return;
}

dwPipeMode = PIPE_READMODE_MESSAGE;
if(!SetNamedPipeHandleState(hPipe, &dwPipeMode, NULL, NULL)) {
(error reporting)
return;
}

if(!GetNamedPipeInfo(hPipe, NULL, NULL, &dwPipeBufferSize, NULL)) {
// This API fails randomly
return;
}

Regards,

Paul Bunn, UltraBac.com, 425-644-6000
Microsoft MVP - WindowsNT/2000
http://www.ultrabac.com