diff options
| author | Ted Ross <tross@apache.org> | 2012-06-06 15:35:17 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2012-06-06 15:35:17 +0000 |
| commit | a162590b8c306d49d699ee322f4a5f99cec70ca5 (patch) | |
| tree | 323f11d71d19869a80ae48c04eb4004024d4b1d9 /qpid/cpp/src | |
| parent | 4aa475342fb91840c5539f830c5614bb0da3b061 (diff) | |
| download | qpid-python-a162590b8c306d49d699ee322f4a5f99cec70ca5.tar.gz | |
QPID-4043 - Remove usage of deprecated definitions from Corosync.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1346951 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/cluster/Cpg.cpp | 54 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/cluster/Cpg.h | 10 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/cluster/types.h | 23 |
3 files changed, 55 insertions, 32 deletions
diff --git a/qpid/cpp/src/qpid/cluster/Cpg.cpp b/qpid/cpp/src/qpid/cluster/Cpg.cpp index 0856bcd824..6e9e22a42f 100644 --- a/qpid/cpp/src/qpid/cluster/Cpg.cpp +++ b/qpid/cpp/src/qpid/cluster/Cpg.cpp @@ -32,7 +32,7 @@ // This is a macro instead of a function because we don't want to // evaluate the MSG argument unless there is an error. #define CPG_CHECK(RESULT, MSG) \ - if ((RESULT) != CPG_OK) throw Exception(errorStr((RESULT), (MSG))) + if ((RESULT) != CS_OK) throw Exception(errorStr((RESULT), (MSG))) namespace qpid { namespace cluster { @@ -50,13 +50,13 @@ Cpg* Cpg::cpgFromHandle(cpg_handle_t handle) { // Applies the same retry-logic to all cpg calls that need it. void Cpg::callCpg ( CpgOp & c ) { - cpg_error_t result; + cs_error_t result; unsigned int snooze = 10; for ( unsigned int nth_try = 0; nth_try < cpgRetries; ++ nth_try ) { - if ( CPG_OK == (result = c.op(handle, & group))) { + if ( CS_OK == (result = c.op(handle, & group))) { break; } - else if ( result == CPG_ERR_TRY_AGAIN ) { + else if ( result == CS_ERR_TRY_AGAIN ) { QPID_LOG(info, "Retrying " << c.opName ); sys::usleep ( snooze ); snooze *= 10; @@ -65,7 +65,7 @@ void Cpg::callCpg ( CpgOp & c ) { else break; // Don't retry unless CPG tells us to. } - if ( result != CPG_OK ) + if ( result != CS_OK ) CPG_CHECK(result, c.msg(group)); } @@ -127,9 +127,9 @@ Cpg::Cpg(Handler& h) : IOHandle(new sys::IOHandlePrivate), handler(h), isShutdow callbacks.cpg_confchg_fn = &globalConfigChange; QPID_LOG(notice, "Initializing CPG"); - cpg_error_t err = cpg_initialize(&handle, &callbacks); + cs_error_t err = cpg_initialize(&handle, &callbacks); int retries = 6; // FIXME aconway 2009-08-06: make this configurable. - while (err == CPG_ERR_TRY_AGAIN && --retries) { + while (err == CS_ERR_TRY_AGAIN && --retries) { QPID_LOG(notice, "Re-trying CPG initialization."); sys::sleep(5); err = cpg_initialize(&handle, &callbacks); @@ -169,11 +169,11 @@ bool Cpg::mcast(const iovec* iov, int iovLen) { if (flowState == CPG_FLOW_CONTROL_ENABLED) return false; - cpg_error_t result; + cs_error_t result; do { result = cpg_mcast_joined(handle, CPG_TYPE_AGREED, const_cast<iovec*>(iov), iovLen); - if (result != CPG_ERR_TRY_AGAIN) CPG_CHECK(result, cantMcastMsg(group)); - } while(result == CPG_ERR_TRY_AGAIN); + if (result != CS_ERR_TRY_AGAIN) CPG_CHECK(result, cantMcastMsg(group)); + } while(result == CS_ERR_TRY_AGAIN); return true; } @@ -187,34 +187,34 @@ void Cpg::shutdown() { } void Cpg::dispatchOne() { - CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_ONE), "Error in CPG dispatch"); + CPG_CHECK(cpg_dispatch(handle,CS_DISPATCH_ONE), "Error in CPG dispatch"); } void Cpg::dispatchAll() { - CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_ALL), "Error in CPG dispatch"); + CPG_CHECK(cpg_dispatch(handle,CS_DISPATCH_ALL), "Error in CPG dispatch"); } void Cpg::dispatchBlocking() { - CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_BLOCKING), "Error in CPG dispatch"); + CPG_CHECK(cpg_dispatch(handle,CS_DISPATCH_BLOCKING), "Error in CPG dispatch"); } -string Cpg::errorStr(cpg_error_t err, const std::string& msg) { +string Cpg::errorStr(cs_error_t err, const std::string& msg) { std::ostringstream os; os << msg << ": "; switch (err) { - case CPG_OK: os << "ok"; break; - case CPG_ERR_LIBRARY: os << "library"; break; - case CPG_ERR_TIMEOUT: os << "timeout"; break; - case CPG_ERR_TRY_AGAIN: os << "try again"; break; - case CPG_ERR_INVALID_PARAM: os << "invalid param"; break; - case CPG_ERR_NO_MEMORY: os << "no memory"; break; - case CPG_ERR_BAD_HANDLE: os << "bad handle"; break; - case CPG_ERR_ACCESS: os << "access denied. You may need to set your group ID to 'ais'"; break; - case CPG_ERR_NOT_EXIST: os << "not exist"; break; - case CPG_ERR_EXIST: os << "exist"; break; - case CPG_ERR_NOT_SUPPORTED: os << "not supported"; break; - case CPG_ERR_SECURITY: os << "security"; break; - case CPG_ERR_TOO_MANY_GROUPS: os << "too many groups"; break; + case CS_OK: os << "ok"; break; + case CS_ERR_LIBRARY: os << "library"; break; + case CS_ERR_TIMEOUT: os << "timeout"; break; + case CS_ERR_TRY_AGAIN: os << "try again"; break; + case CS_ERR_INVALID_PARAM: os << "invalid param"; break; + case CS_ERR_NO_MEMORY: os << "no memory"; break; + case CS_ERR_BAD_HANDLE: os << "bad handle"; break; + case CS_ERR_ACCESS: os << "access denied. You may need to set your group ID to 'ais'"; break; + case CS_ERR_NOT_EXIST: os << "not exist"; break; + case CS_ERR_EXIST: os << "exist"; break; + case CS_ERR_NOT_SUPPORTED: os << "not supported"; break; + case CS_ERR_SECURITY: os << "security"; break; + case CS_ERR_TOO_MANY_GROUPS: os << "too many groups"; break; default: os << ": unknown cpg error " << err; }; os << " (" << err << ")"; diff --git a/qpid/cpp/src/qpid/cluster/Cpg.h b/qpid/cpp/src/qpid/cluster/Cpg.h index 6b81c602bd..1afbce8d75 100644 --- a/qpid/cpp/src/qpid/cluster/Cpg.h +++ b/qpid/cpp/src/qpid/cluster/Cpg.h @@ -131,7 +131,7 @@ class Cpg : public sys::IOHandle { CpgOp ( std::string opName ) : opName(opName) { } - virtual cpg_error_t op ( cpg_handle_t handle, struct cpg_name * ) = 0; + virtual cs_error_t op ( cpg_handle_t handle, struct cpg_name * ) = 0; virtual std::string msg(const Name&) = 0; virtual ~CpgOp ( ) { } }; @@ -141,7 +141,7 @@ class Cpg : public sys::IOHandle { CpgJoinOp ( ) : CpgOp ( std::string("cpg_join") ) { } - cpg_error_t op(cpg_handle_t handle, struct cpg_name * group) { + cs_error_t op(cpg_handle_t handle, struct cpg_name * group) { return cpg_join ( handle, group ); } @@ -152,7 +152,7 @@ class Cpg : public sys::IOHandle { CpgLeaveOp ( ) : CpgOp ( std::string("cpg_leave") ) { } - cpg_error_t op(cpg_handle_t handle, struct cpg_name * group) { + cs_error_t op(cpg_handle_t handle, struct cpg_name * group) { return cpg_leave ( handle, group ); } @@ -163,7 +163,7 @@ class Cpg : public sys::IOHandle { CpgFinalizeOp ( ) : CpgOp ( std::string("cpg_finalize") ) { } - cpg_error_t op(cpg_handle_t handle, struct cpg_name *) { + cs_error_t op(cpg_handle_t handle, struct cpg_name *) { return cpg_finalize ( handle ); } @@ -177,7 +177,7 @@ class Cpg : public sys::IOHandle { CpgLeaveOp cpgLeaveOp; CpgFinalizeOp cpgFinalizeOp; - static std::string errorStr(cpg_error_t err, const std::string& msg); + static std::string errorStr(cs_error_t err, const std::string& msg); static std::string cantJoinMsg(const Name&); static std::string cantLeaveMsg(const Name&); static std::string cantMcastMsg(const Name&); diff --git a/qpid/cpp/src/qpid/cluster/types.h b/qpid/cpp/src/qpid/cluster/types.h index bfb4fd5b9e..c8ffb0b804 100644 --- a/qpid/cpp/src/qpid/cluster/types.h +++ b/qpid/cpp/src/qpid/cluster/types.h @@ -34,6 +34,29 @@ extern "C" { #if defined (HAVE_OPENAIS_CPG_H) # include <openais/cpg.h> + +// Provide translations back to the deprecated definitions in openais +typedef cpg_error_t cs_error_t; +#define CS_DISPATCH_ONE CPG_DISPATCH_ONE +#define CS_DISPATCH_ALL CPG_DISPATCH_ALL +#define CS_DISPATCH_BLOCKING CPG_DISPATCH_BLOCKING +#define CS_FLOW_CONTROL_DISABLED CPG_FLOW_CONTROL_DISABLED +#define CS_FLOW_CONTROL_ENABLED CPG_FLOW_CONTROL_ENABLED +#define CS_OK CPG_OK +#define CS_ERR_LIBRARY CPG_ERR_LIBRARY +#define CS_ERR_TIMEOUT CPG_ERR_TIMEOUT +#define CS_ERR_TRY_AGAIN CPG_ERR_TRY_AGAIN +#define CS_ERR_INVALID_PARAM CPG_ERR_INVALID_PARAM +#define CS_ERR_NO_MEMORY CPG_ERR_NO_MEMORY +#define CS_ERR_BAD_HANDLE CPG_ERR_BAD_HANDLE +#define CS_ERR_BUSY CPG_ERR_BUSY +#define CS_ERR_ACCESS CPG_ERR_ACCESS +#define CS_ERR_NOT_EXIST CPG_ERR_NOT_EXIST +#define CS_ERR_EXIST CPG_ERR_EXIST +#define CS_ERR_NOT_SUPPORTED CPG_ERR_NOT_SUPPORTED +#define CS_ERR_SECURITY CPG_ERR_SECURITY +#define CS_ERR_TOO_MANY_GROUPS CPG_ERR_TOO_MANY_GROUPS + #elif defined (HAVE_COROSYNC_CPG_H) # include <corosync/cpg.h> #else |
