Changes due to continued development effort.

This commit is contained in:
Juan Carlos Luciani
2006-04-28 18:59:15 +00:00
parent fe756d9f5e
commit 3f76e165ad
4 changed files with 146 additions and 59 deletions

View File

@@ -32,6 +32,8 @@
#define INITIAL_RESPONSE_DATA_BUF_SIZE 1028
#define INCREMENT_RESPONSE_DATA_BUF_SIZE 256
#define MAX_RPC_RETRIES 3
//===[ Function prototypes ]===============================================
//===[ Global variables ]==================================================
@@ -54,12 +56,13 @@ CopyMultiToWideAlloc(
//
// Notes:
//
// L0
// L2
//=======================================================================--
{
int retStatus;
int size, i;
DbgTrace(2, "-CopyMultiToWideAlloc- Start\n", 0);
size = (multiSize + 1) * sizeof(WCHAR);
@@ -106,11 +109,12 @@ OpenRpcSession(
//
// Notes:
//
// L0
// L2
//=======================================================================--
{
RpcSession *pSession;
DbgTrace(1, "-OpenRpcSession- Start\n", 0);
// Allocate space for the session
@@ -195,7 +199,7 @@ CloseRpcSession(
//
// Notes:
//
// L0
// L2
//=======================================================================--
{
DbgTrace(1, "-CloseRpcSession- Start\n", 0);
@@ -214,8 +218,9 @@ CloseRpcSession(
//++=======================================================================
static
CasaStatus
Rpc(
InternalRpc(
IN RpcSession *pSession,
IN char *pMethod,
IN bool secure,
@@ -231,7 +236,7 @@ Rpc(
//
// Notes:
//
// L0
// L2
//=======================================================================--
{
CasaStatus retStatus = CASA_STATUS_SUCCESS;
@@ -240,7 +245,7 @@ Rpc(
int wideRpcTargetLen;
WCHAR sendHeaders[] = L"Content-Type: text/html";
DbgTrace(1, "-Rpc- Start\n", 0);
DbgTrace(1, "-InternalRpc- Start\n", 0);
// Initialize output parameter
*ppResponseData = NULL;
@@ -255,8 +260,6 @@ Rpc(
{
HINTERNET hRequest;
// tbd - Add retry capability
// Open a request handle
hRequest = WinHttpOpenRequest(pSession->hConnection,
L"POST",
@@ -334,7 +337,7 @@ Rpc(
}
else
{
DbgTrace(0, "-Rpc- Buffer allocation failure\n", 0);
DbgTrace(0, "-InternalRpc- Buffer allocation failure\n", 0);
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
CASA_FACILITY_AUTHTOKEN,
CASA_STATUS_INSUFFICIENT_RESOURCES);
@@ -343,7 +346,7 @@ Rpc(
}
else
{
DbgTrace(0, "-Rpc- Failed reading response data, error = %d\n", GetLastError());
DbgTrace(0, "-InternalRpc- Failed reading response data, error = %d\n", GetLastError());
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
CASA_FACILITY_AUTHTOKEN,
CASA_STATUS_UNSUCCESSFUL);
@@ -366,7 +369,7 @@ Rpc(
}
else
{
DbgTrace(0, "-Rpc- Buffer allocation failure\n", 0);
DbgTrace(0, "-InternalRpc- Buffer allocation failure\n", 0);
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
CASA_FACILITY_AUTHTOKEN,
CASA_STATUS_INSUFFICIENT_RESOURCES);
@@ -374,7 +377,7 @@ Rpc(
}
else
{
DbgTrace(0, "-Rpc- HTTP request did not complete successfully, status = %S\n", httpCompStatus);
DbgTrace(0, "-InternalRpc- HTTP request did not complete successfully, status = %S\n", httpCompStatus);
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
CASA_FACILITY_AUTHTOKEN,
CASA_STATUS_UNSUCCESSFUL);
@@ -382,7 +385,7 @@ Rpc(
}
else
{
DbgTrace(0, "-Rpc- Unable to obtain http request completion status, error = %d\n", GetLastError());
DbgTrace(0, "-InternalRpc- Unable to obtain http request completion status, error = %d\n", GetLastError());
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
CASA_FACILITY_AUTHTOKEN,
CASA_STATUS_UNSUCCESSFUL);
@@ -390,7 +393,7 @@ Rpc(
}
else
{
DbgTrace(0, "-Rpc- Unable to receive response, error = %d\n", GetLastError());
DbgTrace(0, "-InternalRpc- Unable to receive response, error = %d\n", GetLastError());
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
CASA_FACILITY_AUTHTOKEN,
CASA_STATUS_UNSUCCESSFUL);
@@ -400,7 +403,7 @@ Rpc(
{
int error = GetLastError();
DbgTrace(0, "-Rpc- Unsuccessful send http request, error = %d\n", error);
DbgTrace(0, "-InternalRpc- Unsuccessful send http request, error = %d\n", error);
if (error == ERROR_WINHTTP_CANNOT_CONNECT)
{
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
@@ -420,7 +423,7 @@ Rpc(
}
else
{
DbgTrace(0, "-Rpc- Unable to open http request, error = %d\n", GetLastError());
DbgTrace(0, "-InternalRpc- Unable to open http request, error = %d\n", GetLastError());
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
CASA_FACILITY_AUTHTOKEN,
CASA_STATUS_UNSUCCESSFUL);
@@ -431,12 +434,65 @@ Rpc(
}
else
{
DbgTrace(0, "-Rpc- Error converting method name to wide string\n", 0);
DbgTrace(0, "-InternalRpc- Error converting method name to wide string\n", 0);
}
DbgTrace(1, "-InternalRpc- End, retStatus = %d\n", retStatus);
return retStatus;
}
//++=======================================================================
CasaStatus
Rpc(
IN RpcSession *pSession,
IN char *pMethod,
IN bool secure,
IN char *pRequestData,
INOUT char **ppResponseData,
INOUT int *pResponseDataLen)
//
// Arguments:
//
// Returns:
//
// Abstract:
//
// Notes:
//
// L2
//=======================================================================--
{
CasaStatus retStatus;
int retries = 0;
DbgTrace(1, "-Rpc- Start\n", 0);
// Retry the RPC as needed
do
{
// Issue the RPC
retStatus = InternalRpc(pSession,
pMethod,
secure,
pRequestData,
ppResponseData,
pResponseDataLen);
// Account for this try
retries ++;
} while (CasaStatusCode(retStatus) == CASA_STATUS_AUTH_SERVER_UNAVAILABLE
&& retries < MAX_RPC_RETRIES);
DbgTrace(1, "-Rpc- End, retStatus = %d\n", retStatus);
return retStatus;
}
//++=======================================================================
//++=======================================================================
//++=======================================================================