diff --git a/CASA/micasacache/sscs_ipc.c b/CASA/micasacache/sscs_ipc.c index 282c95e4..c03ce446 100644 --- a/CASA/micasacache/sscs_ipc.c +++ b/CASA/micasacache/sscs_ipc.c @@ -94,23 +94,37 @@ void * ipc_win_create() //#ifdef SSCS_WIN32_PLAT_F // connect to the named Pipe HANDLE hPipe = NULL; - int rcode; + int rcode = 0, i; DWORD mode = PIPE_READMODE_MESSAGE; DbgTrace(1, " -ipc_win_create- start\n", 0); - hPipe = CreateFile( - XTIER_RPC_PIPE, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, //null, - OPEN_EXISTING, - 0, - 0); + for (i = 0; i < 5; i++) { + hPipe = CreateFile( + XTIER_RPC_PIPE, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, //null, + OPEN_EXISTING, + 0, + 0); + + if (hPipe != INVALID_HANDLE_VALUE) + break; + + rcode = GetLastError(); + + if (rcode != ERROR_PIPE_BUSY) + break; + + if (!WaitNamedPipe(XTIER_RPC_PIPE, 5000)) { + rcode = GetLastError(); + break; + } + } if (hPipe == INVALID_HANDLE_VALUE) { - rcode = GetLastError(); DbgTrace(0, " Create Pipe error:%d\r\n", rcode); return -1; }