Changes due to continued development effort.
This commit is contained in:
		| @@ -44,7 +44,10 @@ | |||||||
| //===[ Global variables ]================================================== | //===[ Global variables ]================================================== | ||||||
|  |  | ||||||
| // In memory auth cache list head | // In memory auth cache list head | ||||||
| LIST_ENTRY  authCacheListHead; | LIST_ENTRY  g_authCacheListHead; | ||||||
|  |  | ||||||
|  | // Non-host specific key name | ||||||
|  | char  g_allHosts[] = "AllHosts"; | ||||||
|  |  | ||||||
|  |  | ||||||
| //++======================================================================= | //++======================================================================= | ||||||
| @@ -61,13 +64,19 @@ CreateAuthCacheEntry( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    AuthCacheEntry *pEntry; |    AuthCacheEntry *pEntry; | ||||||
|  |  | ||||||
|    DbgTrace(1, "-CreateAuthCacheEntry- Start\n", 0); |    DbgTrace(1, "-CreateAuthCacheEntry- Start\n", 0); | ||||||
|  |  | ||||||
|  |    // Use allHosts if a host name was not specified | ||||||
|  |    if (pHostName == NULL) | ||||||
|  |    { | ||||||
|  |       pHostName = g_allHosts; | ||||||
|  |    } | ||||||
|  |  | ||||||
|    // Allocate space for the entry |    // Allocate space for the entry | ||||||
|    pEntry = (AuthCacheEntry*) malloc(sizeof(*pEntry)); |    pEntry = (AuthCacheEntry*) malloc(sizeof(*pEntry)); | ||||||
|    if (pEntry) |    if (pEntry) | ||||||
| @@ -133,7 +142,7 @@ FreeAuthCacheEntry( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    DbgTrace(1, "-FreeAuthCacheEntry- Start\n", 0); |    DbgTrace(1, "-FreeAuthCacheEntry- Start\n", 0); | ||||||
| @@ -170,7 +179,7 @@ CacheEntryLifetimeExpired( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    DWORD currentTime = GetTickCount(); |    DWORD currentTime = GetTickCount(); | ||||||
| @@ -237,7 +246,7 @@ FindEntryInAuthCache( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    AuthCacheEntry *pEntry = NULL; |    AuthCacheEntry *pEntry = NULL; | ||||||
| @@ -248,9 +257,15 @@ FindEntryInAuthCache( | |||||||
|    // Examine the cache, if entry found then check if it has expired |    // Examine the cache, if entry found then check if it has expired | ||||||
|    // in which case we would want to remove it from the cache. |    // in which case we would want to remove it from the cache. | ||||||
|  |  | ||||||
|  |    // Use allHosts if a host name was not specified | ||||||
|  |    if (pHostName == NULL) | ||||||
|  |    { | ||||||
|  |       pHostName = g_allHosts; | ||||||
|  |    } | ||||||
|  |  | ||||||
|    // First look through the entries in our in-memory cache |    // First look through the entries in our in-memory cache | ||||||
|    pListEntry = authCacheListHead.Flink; |    pListEntry = g_authCacheListHead.Flink; | ||||||
|    while (pListEntry != &authCacheListHead) |    while (pListEntry != &g_authCacheListHead) | ||||||
|    { |    { | ||||||
|       AuthCacheEntry *pWrkEntry; |       AuthCacheEntry *pWrkEntry; | ||||||
|  |  | ||||||
| @@ -410,7 +425,7 @@ FindEntryInAuthCache( | |||||||
|                                           // add it to the in-memory cache. |                                           // add it to the in-memory cache. | ||||||
|                                           entryInitialized = TRUE; |                                           entryInitialized = TRUE; | ||||||
|                                           deleteCacheKeyNameKey = FALSE; |                                           deleteCacheKeyNameKey = FALSE; | ||||||
|                                           InsertHeadList(&authCacheListHead, &pEntry->listEntry); |                                           InsertHeadList(&g_authCacheListHead, &pEntry->listEntry); | ||||||
|                                        } |                                        } | ||||||
|                                        else |                                        else | ||||||
|                                        { |                                        { | ||||||
| @@ -435,7 +450,7 @@ FindEntryInAuthCache( | |||||||
|                                  // add it to the in-memory cache. |                                  // add it to the in-memory cache. | ||||||
|                                  entryInitialized = TRUE; |                                  entryInitialized = TRUE; | ||||||
|                                  deleteCacheKeyNameKey = FALSE; |                                  deleteCacheKeyNameKey = FALSE; | ||||||
|                                  InsertHeadList(&authCacheListHead, &pEntry->listEntry); |                                  InsertHeadList(&g_authCacheListHead, &pEntry->listEntry); | ||||||
|                               } |                               } | ||||||
|                            } |                            } | ||||||
|                            else |                            else | ||||||
| @@ -509,7 +524,7 @@ AddEntryToAuthCache( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    LONG  status; |    LONG  status; | ||||||
| @@ -653,7 +668,7 @@ AddEntryToAuthCache( | |||||||
|    { |    { | ||||||
|       // The entry was added to the cache, save it in |       // The entry was added to the cache, save it in | ||||||
|       // our in-memory cache. |       // our in-memory cache. | ||||||
|       InsertHeadList(&authCacheListHead, &pEntry->listEntry); |       InsertHeadList(&g_authCacheListHead, &pEntry->listEntry); | ||||||
|    } |    } | ||||||
|    else |    else | ||||||
|    { |    { | ||||||
| @@ -678,7 +693,7 @@ InitializeAuthCache(void) | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    CasaStatus                 retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, |    CasaStatus                 retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
| @@ -690,7 +705,7 @@ InitializeAuthCache(void) | |||||||
|    DbgTrace(1, "-InitializeAuthCache- Start\n", 0); |    DbgTrace(1, "-InitializeAuthCache- Start\n", 0); | ||||||
|  |  | ||||||
|    // Initialize the cache list head |    // Initialize the cache list head | ||||||
|    InitializeListHead(&authCacheListHead); |    InitializeListHead(&g_authCacheListHead); | ||||||
|  |  | ||||||
|    // Lets create the CASA Auth Cache registry key in the |    // Lets create the CASA Auth Cache registry key in the | ||||||
|    // user's hive and limit access to it. |    // user's hive and limit access to it. | ||||||
| @@ -873,3 +888,8 @@ InitializeAuthCache(void) | |||||||
|    return retStatus; |    return retStatus; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //++======================================================================= | ||||||
|  | //++======================================================================= | ||||||
|  | //++======================================================================= | ||||||
|  |  | ||||||
|   | |||||||
| @@ -44,17 +44,23 @@ | |||||||
| // | // | ||||||
| // DbgTrace macro define | // DbgTrace macro define | ||||||
| // | // | ||||||
|  | //#define DbgTrace(LEVEL, X, Y) {                          \ | ||||||
|  | //char printBuff[256];                                     \ | ||||||
|  | //   if (LEVEL == 0 || DebugLevel >= LEVEL)                \ | ||||||
|  | //   {                                                     \ | ||||||
|  | //      _snprintf(printBuff, sizeof(printBuff), X, Y);     \ | ||||||
|  | //      printf("AuthToken %s", printBuff);                 \ | ||||||
|  | //   }                                                     \ | ||||||
|  | //} | ||||||
| #define DbgTrace(LEVEL, X, Y) {                                \ | #define DbgTrace(LEVEL, X, Y) {                                \ | ||||||
|  | char formatBuff[128];                                          \ | ||||||
| char printBuff[256];                                           \ | char printBuff[256];                                           \ | ||||||
|    if (LEVEL == 0)                                       \ |    if (LEVEL == 0 || DebugLevel >= LEVEL)                      \ | ||||||
|    {                                                           \ |    {                                                           \ | ||||||
|       _snprintf(printBuff, sizeof(printBuff), X, Y);     \ |       strcpy(formatBuff, "AuthToken ");                        \ | ||||||
|       printf("AuthToken %s", printBuff);                 \ |       strncat(formatBuff, X, sizeof(formatBuff) - 10);         \ | ||||||
|    }                                                     \ |       _snprintf(printBuff, sizeof(printBuff), formatBuff, Y);  \ | ||||||
|    else if (DebugLevel >= LEVEL)                         \ |       OutputDebugString(printBuff);                            \ | ||||||
|    {                                                     \ |  | ||||||
|       _snprintf(printBuff, sizeof(printBuff), X, Y);     \ |  | ||||||
|       printf("AuthToken %s", printBuff);                 \ |  | ||||||
|    }                                                           \ |    }                                                           \ | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -76,7 +76,7 @@ CreateUserMutex(void) | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    CasaStatus  retStatus = CASA_STATUS_SUCCESS; |    CasaStatus  retStatus = CASA_STATUS_SUCCESS; | ||||||
| @@ -99,8 +99,6 @@ CreateUserMutex(void) | |||||||
|             SECURITY_ATTRIBUTES  mutexAttributes; |             SECURITY_ATTRIBUTES  mutexAttributes; | ||||||
|             char                 mutexName[256]; |             char                 mutexName[256]; | ||||||
|  |  | ||||||
|             //printf("\nUsername is %s", pUsername); |  | ||||||
|  |  | ||||||
|             // Now lets create a global semaphore for the |             // Now lets create a global semaphore for the | ||||||
|             // user and allow its handle to be inherited. |             // user and allow its handle to be inherited. | ||||||
|             mutexAttributes.nLength = sizeof(mutexAttributes); |             mutexAttributes.nLength = sizeof(mutexAttributes); | ||||||
| @@ -162,7 +160,7 @@ CreateUserMutex(void) | |||||||
|  |  | ||||||
| //++======================================================================= | //++======================================================================= | ||||||
| void | void | ||||||
| LockUserMutex(void) | AcquireUserMutex(void) | ||||||
| // | // | ||||||
| //  Arguments:  | //  Arguments:  | ||||||
| // | // | ||||||
| @@ -172,20 +170,20 @@ LockUserMutex(void) | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    DbgTrace(2, "-LockUserMutex- Start\n", 0); |    DbgTrace(2, "-AcquireUserMutex- Start\n", 0); | ||||||
|  |  | ||||||
|    WaitForSingleObject(hUserMutex, INFINITE); |    WaitForSingleObject(hUserMutex, INFINITE); | ||||||
|  |  | ||||||
|    DbgTrace(2, "-LockUserMutex- End\n", 0); |    DbgTrace(2, "-AcquireUserMutex- End\n", 0); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| //++======================================================================= | //++======================================================================= | ||||||
| void | void | ||||||
| FreeUserMutex(void) | ReleaseUserMutex(void) | ||||||
| // | // | ||||||
| //  Arguments:  | //  Arguments:  | ||||||
| // | // | ||||||
| @@ -195,17 +193,17 @@ FreeUserMutex(void) | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    DbgTrace(2, "-FreeUserMutex- Start\n", 0); |    DbgTrace(2, "-ReleaseUserMutex- Start\n", 0); | ||||||
|  |  | ||||||
|    if (ReleaseMutex(hUserMutex) == 0) |    if (ReleaseMutex(hUserMutex) == 0) | ||||||
|    { |    { | ||||||
|       DbgTrace(0, "-FreeUserMutex- ReleaseMutex failed, error = %d\n", GetLastError()); |       DbgTrace(0, "-ReleaseUserMutex- ReleaseMutex failed, error = %d\n", GetLastError()); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    DbgTrace(2, "-FreeUserMutex- End\n", 0); |    DbgTrace(2, "-ReleaseUserMutex- End\n", 0); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -222,7 +220,7 @@ OpenLibrary( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L0 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    LIB_HANDLE  libHandle; |    LIB_HANDLE  libHandle; | ||||||
| @@ -255,7 +253,7 @@ CloseLibrary( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L0 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    DbgTrace(1, "-CloseLibrary- Start\n", 0); |    DbgTrace(1, "-CloseLibrary- Start\n", 0); | ||||||
| @@ -280,11 +278,12 @@ GetFunctionPtr( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L0 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    void  *pFuncPtr; |    void  *pFuncPtr; | ||||||
|  |  | ||||||
|  |  | ||||||
|    DbgTrace(1, "-GetFunctionPtr- Start\n", 0); |    DbgTrace(1, "-GetFunctionPtr- Start\n", 0); | ||||||
|  |  | ||||||
|    pFuncPtr = GetProcAddress(libHandle, pFunctionName); |    pFuncPtr = GetProcAddress(libHandle, pFunctionName); | ||||||
| @@ -312,13 +311,14 @@ NormalizeHostName( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    char                          *pNormalizedName = NULL; |    char                          *pNormalizedName = NULL; | ||||||
|    LIST_ENTRY                    *pListEntry; |    LIST_ENTRY                    *pListEntry; | ||||||
|    NormalizedHostNameCacheEntry  *pEntry = NULL; |    NormalizedHostNameCacheEntry  *pEntry = NULL; | ||||||
|  |  | ||||||
|  |  | ||||||
|    DbgTrace(1, "-NormalizeHostName- Start\n", 0); |    DbgTrace(1, "-NormalizeHostName- Start\n", 0); | ||||||
|  |  | ||||||
|    // Obtain our synchronization mutex |    // Obtain our synchronization mutex | ||||||
| @@ -502,7 +502,7 @@ InitializeHostNameNormalization(void) | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L1 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    CasaStatus  retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, |    CasaStatus  retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
| @@ -542,3 +542,8 @@ InitializeHostNameNormalization(void) | |||||||
|    return retStatus; |    return retStatus; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //++======================================================================= | ||||||
|  | //++======================================================================= | ||||||
|  | //++======================================================================= | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,6 +32,8 @@ | |||||||
| #define INITIAL_RESPONSE_DATA_BUF_SIZE 1028 | #define INITIAL_RESPONSE_DATA_BUF_SIZE 1028 | ||||||
| #define INCREMENT_RESPONSE_DATA_BUF_SIZE 256 | #define INCREMENT_RESPONSE_DATA_BUF_SIZE 256 | ||||||
|  |  | ||||||
|  | #define MAX_RPC_RETRIES 3 | ||||||
|  |  | ||||||
| //===[ Function prototypes ]=============================================== | //===[ Function prototypes ]=============================================== | ||||||
|  |  | ||||||
| //===[ Global variables ]================================================== | //===[ Global variables ]================================================== | ||||||
| @@ -54,12 +56,13 @@ CopyMultiToWideAlloc( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L0 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    int      retStatus; |    int      retStatus; | ||||||
|    int      size, i; |    int      size, i; | ||||||
|  |  | ||||||
|  |  | ||||||
|    DbgTrace(2, "-CopyMultiToWideAlloc- Start\n", 0); |    DbgTrace(2, "-CopyMultiToWideAlloc- Start\n", 0); | ||||||
|  |  | ||||||
|    size = (multiSize + 1) * sizeof(WCHAR); |    size = (multiSize + 1) * sizeof(WCHAR); | ||||||
| @@ -106,11 +109,12 @@ OpenRpcSession( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L0 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    RpcSession  *pSession; |    RpcSession  *pSession; | ||||||
|  |  | ||||||
|  |  | ||||||
|    DbgTrace(1, "-OpenRpcSession- Start\n", 0); |    DbgTrace(1, "-OpenRpcSession- Start\n", 0); | ||||||
|  |  | ||||||
|    // Allocate space for the session |    // Allocate space for the session | ||||||
| @@ -195,7 +199,7 @@ CloseRpcSession( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L0 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    DbgTrace(1, "-CloseRpcSession- Start\n", 0); |    DbgTrace(1, "-CloseRpcSession- Start\n", 0); | ||||||
| @@ -214,8 +218,9 @@ CloseRpcSession( | |||||||
|  |  | ||||||
|  |  | ||||||
| //++======================================================================= | //++======================================================================= | ||||||
|  | static | ||||||
| CasaStatus | CasaStatus | ||||||
| Rpc( | InternalRpc( | ||||||
|    IN    RpcSession *pSession, |    IN    RpcSession *pSession, | ||||||
|    IN    char *pMethod, |    IN    char *pMethod, | ||||||
|    IN    bool secure, |    IN    bool secure, | ||||||
| @@ -231,7 +236,7 @@ Rpc( | |||||||
| // | // | ||||||
| //  Notes: | //  Notes: | ||||||
| // | // | ||||||
| // L0 | // L2 | ||||||
| //=======================================================================-- | //=======================================================================-- | ||||||
| { | { | ||||||
|    CasaStatus  retStatus = CASA_STATUS_SUCCESS; |    CasaStatus  retStatus = CASA_STATUS_SUCCESS; | ||||||
| @@ -240,7 +245,7 @@ Rpc( | |||||||
|    int         wideRpcTargetLen; |    int         wideRpcTargetLen; | ||||||
|    WCHAR       sendHeaders[] = L"Content-Type: text/html"; |    WCHAR       sendHeaders[] = L"Content-Type: text/html"; | ||||||
|  |  | ||||||
|    DbgTrace(1, "-Rpc- Start\n", 0); |    DbgTrace(1, "-InternalRpc- Start\n", 0); | ||||||
|  |  | ||||||
|    // Initialize output parameter |    // Initialize output parameter | ||||||
|    *ppResponseData = NULL; |    *ppResponseData = NULL; | ||||||
| @@ -255,8 +260,6 @@ Rpc( | |||||||
|    { |    { | ||||||
|       HINTERNET   hRequest; |       HINTERNET   hRequest; | ||||||
|  |  | ||||||
|       // tbd - Add retry capability |  | ||||||
|  |  | ||||||
|       // Open a request handle |       // Open a request handle | ||||||
|       hRequest = WinHttpOpenRequest(pSession->hConnection, |       hRequest = WinHttpOpenRequest(pSession->hConnection, | ||||||
|                                     L"POST", |                                     L"POST", | ||||||
| @@ -334,7 +337,7 @@ Rpc( | |||||||
|                                  } |                                  } | ||||||
|                                  else |                                  else | ||||||
|                                  { |                                  { | ||||||
|                                     DbgTrace(0, "-Rpc- Buffer allocation failure\n", 0); |                                     DbgTrace(0, "-InternalRpc- Buffer allocation failure\n", 0); | ||||||
|                                     retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, |                                     retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
|                                                                 CASA_FACILITY_AUTHTOKEN, |                                                                 CASA_FACILITY_AUTHTOKEN, | ||||||
|                                                                 CASA_STATUS_INSUFFICIENT_RESOURCES); |                                                                 CASA_STATUS_INSUFFICIENT_RESOURCES); | ||||||
| @@ -343,7 +346,7 @@ Rpc( | |||||||
|                            } |                            } | ||||||
|                            else |                            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, |                               retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
|                                                           CASA_FACILITY_AUTHTOKEN, |                                                           CASA_FACILITY_AUTHTOKEN, | ||||||
|                                                           CASA_STATUS_UNSUCCESSFUL); |                                                           CASA_STATUS_UNSUCCESSFUL); | ||||||
| @@ -366,7 +369,7 @@ Rpc( | |||||||
|                      } |                      } | ||||||
|                      else |                      else | ||||||
|                      { |                      { | ||||||
|                         DbgTrace(0, "-Rpc- Buffer allocation failure\n", 0); |                         DbgTrace(0, "-InternalRpc- Buffer allocation failure\n", 0); | ||||||
|                         retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, |                         retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
|                                                     CASA_FACILITY_AUTHTOKEN, |                                                     CASA_FACILITY_AUTHTOKEN, | ||||||
|                                                     CASA_STATUS_INSUFFICIENT_RESOURCES); |                                                     CASA_STATUS_INSUFFICIENT_RESOURCES); | ||||||
| @@ -374,7 +377,7 @@ Rpc( | |||||||
|                   } |                   } | ||||||
|                   else |                   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, |                      retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
|                                                  CASA_FACILITY_AUTHTOKEN, |                                                  CASA_FACILITY_AUTHTOKEN, | ||||||
|                                                  CASA_STATUS_UNSUCCESSFUL); |                                                  CASA_STATUS_UNSUCCESSFUL); | ||||||
| @@ -382,7 +385,7 @@ Rpc( | |||||||
|                } |                } | ||||||
|                else |                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, |                   retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
|                                               CASA_FACILITY_AUTHTOKEN, |                                               CASA_FACILITY_AUTHTOKEN, | ||||||
|                                               CASA_STATUS_UNSUCCESSFUL); |                                               CASA_STATUS_UNSUCCESSFUL); | ||||||
| @@ -390,7 +393,7 @@ Rpc( | |||||||
|             } |             } | ||||||
|             else |             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, |                retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
|                                            CASA_FACILITY_AUTHTOKEN, |                                            CASA_FACILITY_AUTHTOKEN, | ||||||
|                                            CASA_STATUS_UNSUCCESSFUL); |                                            CASA_STATUS_UNSUCCESSFUL); | ||||||
| @@ -400,7 +403,7 @@ Rpc( | |||||||
|          { |          { | ||||||
|             int   error = GetLastError(); |             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) |             if (error == ERROR_WINHTTP_CANNOT_CONNECT) | ||||||
|             { |             { | ||||||
|                retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, |                retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
| @@ -420,7 +423,7 @@ Rpc( | |||||||
|       } |       } | ||||||
|       else |       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, |          retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, | ||||||
|                                      CASA_FACILITY_AUTHTOKEN, |                                      CASA_FACILITY_AUTHTOKEN, | ||||||
|                                      CASA_STATUS_UNSUCCESSFUL); |                                      CASA_STATUS_UNSUCCESSFUL); | ||||||
| @@ -431,12 +434,65 @@ Rpc( | |||||||
|    } |    } | ||||||
|    else |    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); |    DbgTrace(1, "-Rpc- End, retStatus = %d\n", retStatus); | ||||||
|  |  | ||||||
|    return retStatus; |    return retStatus; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //++======================================================================= | ||||||
|  | //++======================================================================= | ||||||
|  | //++======================================================================= | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user