Added retries for RPCs that fail due to connection errors.
This commit is contained in:
parent
6219bb156e
commit
e3a00efe33
215
CASA-auth-token/client/include/casa_status.h
Normal file
215
CASA-auth-token/client/include/casa_status.h
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; version 2.1
|
||||||
|
* of the License.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, Novell, Inc.
|
||||||
|
*
|
||||||
|
* To contact Novell about this file by physical or electronic mail,
|
||||||
|
* you may find current contact information at www.novell.com.
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _CASA_STATUS_H_
|
||||||
|
#define _CASA_STATUS_H_
|
||||||
|
|
||||||
|
#if defined(__cplusplus) || defined(c_plusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//===[ Header files specific to this module ]==============================
|
||||||
|
|
||||||
|
#include <micasa_types.h>
|
||||||
|
|
||||||
|
//===[ External data ]==============================
|
||||||
|
|
||||||
|
//===[ External prototypes ]==============================
|
||||||
|
|
||||||
|
//===[ Type definitions ]==============================
|
||||||
|
|
||||||
|
//
|
||||||
|
// CasaStatus type
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// The layed out of status values is as follows:
|
||||||
|
//
|
||||||
|
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
|
||||||
|
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||||
|
// +---+-+-+-+---------------------+-------------------------------+
|
||||||
|
// |Sev|r|r|r| Facility | Code |
|
||||||
|
// +---+-+-+-+---------------------+-------------------------------+
|
||||||
|
//
|
||||||
|
// where
|
||||||
|
//
|
||||||
|
// Sev - is the severity code
|
||||||
|
//
|
||||||
|
// 00 - Success
|
||||||
|
// 01 - Informational
|
||||||
|
// 10 - Warning
|
||||||
|
// 11 - Error
|
||||||
|
//
|
||||||
|
// r - is a reserved bit for internal use
|
||||||
|
//
|
||||||
|
// Facility - is the facility code
|
||||||
|
//
|
||||||
|
// Code - is the facility's status code
|
||||||
|
//
|
||||||
|
typedef uint32_t CasaStatus;
|
||||||
|
|
||||||
|
|
||||||
|
//===[ Manifest constants ]==============================
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define severity codes to be used with CasaStatusBuild macro
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CASA_SEVERITY_SUCCESS 0x0
|
||||||
|
#define CASA_SEVERITY_INFORMATIONAL 0x1
|
||||||
|
#define CASA_SEVERITY_WARNING 0x2
|
||||||
|
#define CASA_SEVERITY_ERROR 0x3
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define the facility codes
|
||||||
|
//
|
||||||
|
// Facility codes will start at 0x800 and then work backwards
|
||||||
|
// in an effort to avoid conflict with other system components.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CASA_FACILITY_AUTHTOKEN 0x7FF
|
||||||
|
#define CASA_FACILITY_KRB5TOKEN 0x7FE
|
||||||
|
#define CASA_FACILITY_PWTOKEN 0x7FD
|
||||||
|
|
||||||
|
//
|
||||||
|
// Codes above FACILITY_SPECIFIC are component specific status codes.
|
||||||
|
// Facility specific status codes are defined in the facilities' header file.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define FACILITY_SPECIFIC 0x00001000
|
||||||
|
|
||||||
|
//
|
||||||
|
// Codes below FACILITY_SPECIFIC are common status codes shared by all components.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CASA_STATUS_SUCCESS ((CasaStatus)0x00000000) // Call completed successfully
|
||||||
|
#define CASA_STATUS_UNSUCCESSFUL ((CasaStatus)0x00000001) // Call completed unsuccessfully
|
||||||
|
#define CASA_STATUS_INVALID_HANDLE ((CasaStatus)0x00000002) // An invalid handle was specified
|
||||||
|
#define CASA_STATUS_INVALID_PARAMETER ((CasaStatus)0x00000003) // An invalid parameter to function was specified
|
||||||
|
#define CASA_STATUS_INSUFFICIENT_RESOURCES ((CasaStatus)0x00000004)
|
||||||
|
#define CASA_STATUS_ACCESS_DENIED ((CasaStatus)0x00000005) // Caller does not have required access rights for operation
|
||||||
|
#define CASA_STATUS_BUFFER_OVERFLOW ((CasaStatus)0x00000006) // The data was too large to fit into the specified buffer
|
||||||
|
#define CASA_STATUS_NO_DATA ((CasaStatus)0x00000007)
|
||||||
|
#define CASA_STATUS_NO_MORE_ENTRIES ((CasaStatus)0x00000008) // No more entries to enumerate
|
||||||
|
#define CASA_STATUS_TIMEOUT ((CasaStatus)0x00000009) // Timed out waiting on resource
|
||||||
|
#define CASA_STATUS_OBJECT_NOT_FOUND ((CasaStatus)0x0000000A)
|
||||||
|
#define CASA_STATUS_CANCELLED ((CasaStatus)0x0000000B) // Request cancelled
|
||||||
|
#define CASA_STATUS_NOT_IMPLEMENTED ((CasaStatus)0x0000000C)
|
||||||
|
#define CASA_STATUS_PENDING ((CasaStatus)0x0000000D) // The request is being processed
|
||||||
|
#define CASA_STATUS_INVALID_STATE ((CasaStatus)0x0000000E)
|
||||||
|
#define CASA_STATUS_INVALID_REQUEST ((CasaStatus)0x0000000F)
|
||||||
|
#define CASA_STATUS_ALREADY_REGISTERED ((CasaStatus)0x00000010)
|
||||||
|
#define CASA_STATUS_ABORTED ((CasaStatus)0x00000011)
|
||||||
|
#define CASA_STATUS_REQUEST_NOT_FOUND ((CasaStatus)0x00000012) // Unable to cancel request because it was not found
|
||||||
|
#define CASA_STATUS_OBJECT_ALREADY_EXISTS ((CasaStatus)0x00000013) // The object being created already exists.
|
||||||
|
#define CASA_STATUS_UNSUPPORTED_PROTOCOL ((CasaStatus)0x00000014) // The object is only accessable through a unsupported protocol.
|
||||||
|
#define CASA_STATUS_REJECTED ((CasaStatus)0x00000015)
|
||||||
|
#define CASA_STATUS_ACCESS_VIOLATION ((CasaStatus)0x00000016)
|
||||||
|
#define CASA_STATUS_NOT_SUPPORTED ((CasaStatus)0x00000017)
|
||||||
|
#define CASA_STATUS_NO_PROVIDERS ((CasaStatus)0x00000018) // No providers are available.
|
||||||
|
#define CASA_STATUS_CONFLICT ((CasaStatus)0x00000019)
|
||||||
|
#define CASA_STATUS_INSUFFICIENT_STORAGE ((CasaStatus)0x0000001A)
|
||||||
|
#define CASA_STATUS_AUTHENTICATION_FAILURE ((CasaStatus)0x0000001B)
|
||||||
|
#define CASA_STATUS_CONFIGURATION_ERROR ((CasaStatus)0x0000001C)
|
||||||
|
#define CASA_STATUS_LIBRARY_LOAD_FAILURE ((CasaStatus)0x0000001D)
|
||||||
|
#define CASA_STATUS_AUTH_SERVER_UNAVAILABLE ((CasaStatus)0x0000001E)
|
||||||
|
#define CASA_STATUS_PROTOCOL_ERROR ((CasaStatus)0x0000001F)
|
||||||
|
#define CASA_STATUS_SERVER_ERROR ((CasaStatus)0x00000020)
|
||||||
|
#define CASA_STATUS_NO_CREDENTIALS ((CasaStatus)0x00000021)
|
||||||
|
#define CASA_STATUS_NOT_CONFIGURED ((CasaStatus)0x00000022)
|
||||||
|
#define CASA_STATUS_INVALID_SERVER_CERTIFICATE ((CasaStatus)0x00000023)
|
||||||
|
#define CASA_STATUS_NAME_RESOLVE_ERROR ((CasaStatus)0x00000024)
|
||||||
|
#define CASA_STATUS_CONNECTION_ERROR ((CasaStatus)0x00000025)
|
||||||
|
|
||||||
|
//===[ Macro definitions ]==============================
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macro for building status error codes
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CasaStatusBuild(severity, facility, errorcode) \
|
||||||
|
((CasaStatus)(((severity) << 30) | ((facility) << 16) | (errorcode)))
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macro for retrieving the facility
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CasaStatusFacility(status) \
|
||||||
|
((CasaStatus)(((CasaStatus)(status) >> 16) & (CasaStatus)0x07FF))
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macro for retrieving severity
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CasaStatusSeverity(status) \
|
||||||
|
((CasaStatus)(((CasaStatus)(status)) >> 30))
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macro for retrieving status code
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CasaStatusCode(status) \
|
||||||
|
((CasaStatus)((CasaStatus)(status) & (CasaStatus)0x0000FFFF))
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macro for checking status code for success
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CASA_SUCCESS(status) \
|
||||||
|
((CasaStatus)(status) >> 30 != CASA_SEVERITY_ERROR)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macro for checking status code for information
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CASA_INFORMATION(status) \
|
||||||
|
((CasaStatus)(status) >> 30 == CASA_SEVERITY_INFORMATIONAL)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macro for checking status code for warning
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CASA_WARNING(status) \
|
||||||
|
((CasaStatus)(status) >> 30 == CASA_SEVERITY_WARNING)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macro for checking status code for error
|
||||||
|
//
|
||||||
|
|
||||||
|
#define CASA_ERROR(status) \
|
||||||
|
((CasaStatus)(status) >> 30 == CASA_SEVERITY_ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
//===[ Function Prototypes ]==============================
|
||||||
|
|
||||||
|
//===[ Global Variables ]==============================
|
||||||
|
|
||||||
|
#if defined(__cplusplus) || defined(c_plusplus)
|
||||||
|
}
|
||||||
|
#endif // #if defined(__cplusplus) || defined(c_plusplus)
|
||||||
|
|
||||||
|
#endif // _CASA_STATUS_H_
|
||||||
|
|
||||||
|
//=========================================================================
|
||||||
|
//=========================================================================
|
||||||
|
// casa_status.h
|
@ -164,6 +164,10 @@ CreateAuthTokenCacheEntry(
|
|||||||
strncat(pKey, "@", keySize);
|
strncat(pKey, "@", keySize);
|
||||||
strncat(pKey, pGroupOrHostName, keySize);
|
strncat(pKey, pGroupOrHostName, keySize);
|
||||||
|
|
||||||
|
DbgTrace(3, "-CreateAuthTokenCacheEntry- Key = %s\n", pKey);
|
||||||
|
DbgTrace(3, "-CreateAuthTokenCacheEntry- Keysize = %d\n", keySize);
|
||||||
|
DbgTrace(3, "-CreateAuthTokenCacheEntry- CredStoreScope = %X\n", pCredStoreScope);
|
||||||
|
|
||||||
miCasaStatus = miCASAWriteBinaryKey(g_hCASAContext,
|
miCasaStatus = miCASAWriteBinaryKey(g_hCASAContext,
|
||||||
CASA_SECRET_DO_NOT_PERSIST_FLAG,
|
CASA_SECRET_DO_NOT_PERSIST_FLAG,
|
||||||
&sessionKeyChain,
|
&sessionKeyChain,
|
||||||
@ -345,6 +349,10 @@ CreateSessionTokenCacheEntry(
|
|||||||
// Verify that the cacheKeyStrLen can be casted to a uint32_t
|
// Verify that the cacheKeyStrLen can be casted to a uint32_t
|
||||||
if (cacheKeyStrLen <= UINT32_MAX)
|
if (cacheKeyStrLen <= UINT32_MAX)
|
||||||
{
|
{
|
||||||
|
DbgTrace(3, "-CreateSessionTokenCacheEntry- Key = %s\n", pCacheKey);
|
||||||
|
DbgTrace(3, "-CreateSessionTokenCacheEntry- Keysize = %d\n", cacheKeyStrLen);
|
||||||
|
DbgTrace(3, "-CreateSessionTokenCacheEntry- CredStoreScope = %X\n", pCredStoreScope);
|
||||||
|
|
||||||
miCasaStatus = miCASAWriteBinaryKey(g_hCASAContext,
|
miCasaStatus = miCASAWriteBinaryKey(g_hCASAContext,
|
||||||
CASA_SECRET_DO_NOT_PERSIST_FLAG,
|
CASA_SECRET_DO_NOT_PERSIST_FLAG,
|
||||||
&sessionKeyChain,
|
&sessionKeyChain,
|
||||||
@ -516,6 +524,10 @@ FindSessionTokenEntryInCache(
|
|||||||
// Verify that the cacheKeyStrLen can be casted to a uint32_t
|
// Verify that the cacheKeyStrLen can be casted to a uint32_t
|
||||||
if (cacheKeyStrLen <= UINT32_MAX)
|
if (cacheKeyStrLen <= UINT32_MAX)
|
||||||
{
|
{
|
||||||
|
DbgTrace(3, "-FindSessionTokenCacheEntry- Key = %s\n", pCacheKey);
|
||||||
|
DbgTrace(3, "-FindSessionTokenCacheEntry- Keysize = %d\n", cacheKeyStrLen);
|
||||||
|
DbgTrace(3, "-FindSessionTokenCacheEntry- CredStoreScope = %X\n", pCredStoreScope);
|
||||||
|
|
||||||
miCasaStatus = miCASAReadBinaryKey(g_hCASAContext,
|
miCasaStatus = miCASAReadBinaryKey(g_hCASAContext,
|
||||||
0,
|
0,
|
||||||
&sessionKeyChain,
|
&sessionKeyChain,
|
||||||
@ -646,6 +658,10 @@ FindAuthTokenEntryInCache(
|
|||||||
valueLength = 0;
|
valueLength = 0;
|
||||||
bytesRequired = 0;
|
bytesRequired = 0;
|
||||||
|
|
||||||
|
DbgTrace(3, "-FindAuthTokenCacheEntry- Key = %s\n", pKey);
|
||||||
|
DbgTrace(3, "-FindAuthTokenCacheEntry- Keysize = %d\n", strlen(pKey) + 1);
|
||||||
|
DbgTrace(3, "-FindAuthTokenCacheEntry- CredStoreScope = %X\n", pCredStoreScope);
|
||||||
|
|
||||||
miCasaStatus = miCASAReadBinaryKey(g_hCASAContext,
|
miCasaStatus = miCASAReadBinaryKey(g_hCASAContext,
|
||||||
0,
|
0,
|
||||||
&sessionKeyChain,
|
&sessionKeyChain,
|
||||||
|
@ -461,9 +461,26 @@ InternalRpc(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgTrace(0, "-OpenRpcSession- Curl perform failed, code = %d\n", curlResult);
|
DbgTrace(0, "-OpenRpcSession- Curl perform failed, code = %d\n", curlResult);
|
||||||
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
|
||||||
CASA_FACILITY_AUTHTOKEN,
|
if (curlResult == CURLE_COULDNT_CONNECT
|
||||||
CASA_STATUS_UNSUCCESSFUL);
|
|| curlResult == CURLE_SSL_CONNECT_ERROR)
|
||||||
|
{
|
||||||
|
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||||
|
CASA_FACILITY_AUTHTOKEN,
|
||||||
|
CASA_STATUS_AUTH_SERVER_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
else if (curlResult == CURLE_OPERATION_TIMEOUTED
|
||||||
|
|| curlResult == CURLE_SEND_ERROR
|
||||||
|
|| curlResult == CURLE_RECV_ERROR)
|
||||||
|
{
|
||||||
|
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||||
|
CASA_FACILITY_AUTHTOKEN,
|
||||||
|
CASA_STATUS_CONNECTION_ERROR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||||
|
CASA_FACILITY_AUTHTOKEN,
|
||||||
|
CASA_STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that we never exit with a recv data buffer hanging off the session
|
// Make sure that we never exit with a recv data buffer hanging off the session
|
||||||
@ -536,7 +553,7 @@ Rpc(
|
|||||||
//=======================================================================--
|
//=======================================================================--
|
||||||
{
|
{
|
||||||
CasaStatus retStatus;
|
CasaStatus retStatus;
|
||||||
int retries = 0;
|
int retries = 3;
|
||||||
|
|
||||||
DbgTrace(1, "-Rpc- Start\n", 0);
|
DbgTrace(1, "-Rpc- Start\n", 0);
|
||||||
|
|
||||||
@ -554,7 +571,7 @@ Rpc(
|
|||||||
// Account for this try
|
// Account for this try
|
||||||
retries ++;
|
retries ++;
|
||||||
|
|
||||||
} while (CasaStatusCode(retStatus) == CASA_STATUS_AUTH_SERVER_UNAVAILABLE
|
} while (CasaStatusCode(retStatus) == CASA_STATUS_CONNECTION_ERROR
|
||||||
&& retries < MAX_RPC_RETRIES);
|
&& retries < MAX_RPC_RETRIES);
|
||||||
|
|
||||||
DbgTrace(1, "-Rpc- End, retStatus = %0X\n", retStatus);
|
DbgTrace(1, "-Rpc- End, retStatus = %0X\n", retStatus);
|
||||||
|
@ -584,7 +584,7 @@ InternalRpc(
|
|||||||
DbgTrace(0, "-InternalRpc- 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_CONNECTION_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -713,7 +713,7 @@ InternalRpc(
|
|||||||
DbgTrace(0, "-InternalRpc- Unsuccessful send http request, error = %d\n", error);
|
DbgTrace(0, "-InternalRpc- Unsuccessful send http request, error = %d\n", error);
|
||||||
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||||
CASA_FACILITY_AUTHTOKEN,
|
CASA_FACILITY_AUTHTOKEN,
|
||||||
CASA_STATUS_UNSUCCESSFUL);
|
CASA_STATUS_CONNECTION_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,7 +776,7 @@ Rpc(
|
|||||||
//=======================================================================--
|
//=======================================================================--
|
||||||
{
|
{
|
||||||
CasaStatus retStatus;
|
CasaStatus retStatus;
|
||||||
int retries = 0;
|
int retries = 3;
|
||||||
|
|
||||||
DbgTrace(1, "-Rpc- Start\n", 0);
|
DbgTrace(1, "-Rpc- Start\n", 0);
|
||||||
|
|
||||||
@ -794,7 +794,9 @@ Rpc(
|
|||||||
// Account for this try
|
// Account for this try
|
||||||
retries ++;
|
retries ++;
|
||||||
|
|
||||||
} while (CasaStatusCode(retStatus) == CASA_STATUS_AUTH_SERVER_UNAVAILABLE
|
|
||||||
|
|
||||||
|
} while (CasaStatusCode(retStatus) == CASA_STATUS_CONNECTION_ERROR
|
||||||
&& retries < MAX_RPC_RETRIES);
|
&& retries < MAX_RPC_RETRIES);
|
||||||
|
|
||||||
DbgTrace(1, "-Rpc- End, retStatus = %0X\n", retStatus);
|
DbgTrace(1, "-Rpc- End, retStatus = %0X\n", retStatus);
|
||||||
|
@ -139,6 +139,7 @@ typedef uint32_t CasaStatus;
|
|||||||
#define CASA_STATUS_NOT_CONFIGURED ((CasaStatus)0x00000022)
|
#define CASA_STATUS_NOT_CONFIGURED ((CasaStatus)0x00000022)
|
||||||
#define CASA_STATUS_INVALID_SERVER_CERTIFICATE ((CasaStatus)0x00000023)
|
#define CASA_STATUS_INVALID_SERVER_CERTIFICATE ((CasaStatus)0x00000023)
|
||||||
#define CASA_STATUS_NAME_RESOLVE_ERROR ((CasaStatus)0x00000024)
|
#define CASA_STATUS_NAME_RESOLVE_ERROR ((CasaStatus)0x00000024)
|
||||||
|
#define CASA_STATUS_CONNECTION_ERROR ((CasaStatus)0x00000025)
|
||||||
|
|
||||||
//===[ Macro definitions ]==============================
|
//===[ Macro definitions ]==============================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user