Changing the RPC retry logic to be bounded by time rather than by the

number of retries to match what is being done in the Windows platform.
This commit is contained in:
Juan Carlos Luciani 2008-07-09 17:51:22 +00:00
parent d55e7138fc
commit 215bd98dd5

View File

@ -30,6 +30,8 @@
//===[ Type definitions ]================================================== //===[ Type definitions ]==================================================
#define MAX_RPC_RETRIES 3 #define MAX_RPC_RETRIES 3
#define MILLISECONDS_BETWEEN_RPC_RETRIES 3000
#define MAX_RPC_TIME_MILLISECONDS 60000
//===[ External prototypes ]=============================================== //===[ External prototypes ]===============================================
@ -554,12 +556,37 @@ Rpc(
{ {
CasaStatus retStatus; CasaStatus retStatus;
int retries = 0; int retries = 0;
DWORD startTime = GetTickCount();
DWORD currentTime;
DbgTrace(1, "-Rpc- Start\n", 0); DbgTrace(1, "-Rpc- Start\n", 0);
// Retry the RPC as needed // Retry the RPC as needed
do do
{ {
// Check if this is a retry
if (retries != 0)
{
// This is a retry, check if we should keep retrying.
currentTime = GetTickCount();
if (currentTime > startTime)
{
if ((currentTime - startTime) > MAX_RPC_TIME_MILLISECONDS)
{
DbgTrace(1, "-Rpc- Stopping after %d retries\n", retries);
break;
}
}
else
{
// The clock must have wrapped, treat it as if no time has elapsed.
startTime = currentTime;
}
// Pause before the next retry
usleep(MILLISECONDS_BETWEEN_RPC_RETRIES * 1000);
}
// Issue the RPC // Issue the RPC
retStatus = InternalRpc(pSession, retStatus = InternalRpc(pSession,
pMethod, pMethod,
@ -571,8 +598,7 @@ Rpc(
// Account for this try // Account for this try
retries ++; retries ++;
} while (CasaStatusCode(retStatus) == CASA_STATUS_CONNECTION_ERROR } while (CasaStatusCode(retStatus) == CASA_STATUS_CONNECTION_ERROR);
&& retries < MAX_RPC_RETRIES);
DbgTrace(1, "-Rpc- End, retStatus = %0X\n", retStatus); DbgTrace(1, "-Rpc- End, retStatus = %0X\n", retStatus);