From 9327d9b56ca832302c36548329d83688d4f5bdb4 Mon Sep 17 00:00:00 2001 From: S Rahul Date: Wed, 15 Apr 2009 04:21:32 +0000 Subject: [PATCH] Bug#489688: While trying to open named pipe to talk to micasad, micasa client may get an error ERROR_PIPE_BUSY. Client has to retry operation. --- CASA/micasacache/sscs_ipc.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) 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; }