Enhanced the RPC retry logic for the Windows client to be bounded by time rather than number of retries. Also, added a pause between retries to avoid saturating the network. The corresponding Linux client changes still need to be made. This changes allow us to support large number of clients against a single server.

This commit is contained in:
Juan Carlos Luciani 2008-07-03 20:41:23 +00:00
parent 8d0d55a666
commit 8ea377f845
3 changed files with 44 additions and 6 deletions

View File

@ -553,7 +553,7 @@ Rpc(
//=======================================================================--
{
CasaStatus retStatus;
int retries = 3;
int retries = 0;
DbgTrace(1, "-Rpc- Start\n", 0);

View File

@ -543,6 +543,20 @@ NormalizeHostName(
else
{
DbgTrace(0, "-NormalizeHostName- Name resolution failed, error = %d\n", WSAGetLastError());
// Not able to resolve the name in DNS, just use the host name as
// the normalized name.
pEntry->buffLengthRequired = strlen(pHostName) + 1;
pEntry->pNormalizedHostName = (char*) malloc(pEntry->buffLengthRequired);
if (pEntry->pNormalizedHostName)
{
// Copy the host name
strcpy(pEntry->pNormalizedHostName, pHostName);
}
else
{
DbgTrace(0, "-NormalizeHostName- Buffer allocation error\n", 0);
}
}
}
else

View File

@ -33,6 +33,8 @@
#define INCREMENT_RESPONSE_DATA_BUF_SIZE 256
#define MAX_RPC_RETRIES 3
#define MILLISECONDS_BETWEEN_RPC_RETRIES 3000
#define MAX_RPC_TIME_MILLISECONDS 60000
//===[ Function prototypes ]===============================================
@ -776,13 +778,38 @@ Rpc(
//=======================================================================--
{
CasaStatus retStatus;
int retries = 3;
int retries = 0;
DWORD startTime = GetTickCount();
DWORD currentTime;
DbgTrace(1, "-Rpc- Start\n", 0);
// Retry the RPC as needed
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
Sleep(MILLISECONDS_BETWEEN_RPC_RETRIES);
}
// Issue the RPC
retStatus = InternalRpc(pSession,
pMethod,
@ -794,10 +821,7 @@ Rpc(
// Account for this try
retries ++;
} while (CasaStatusCode(retStatus) == CASA_STATUS_CONNECTION_ERROR
&& retries < MAX_RPC_RETRIES);
} while (CasaStatusCode(retStatus) == CASA_STATUS_CONNECTION_ERROR);
DbgTrace(1, "-Rpc- End, retStatus = %0X\n", retStatus);