1 --- qpidc-0.16/src/qpid/cluster/Cpg.cpp.orig 2010-02-26 17:47:23.000000000 +0100
2 +++ qpidc-0.16/src/qpid/cluster/Cpg.cpp 2020-12-13 07:18:53.042400272 +0100
4 // This is a macro instead of a function because we don't want to
5 // evaluate the MSG argument unless there is an error.
6 #define CPG_CHECK(RESULT, MSG) \
7 - if ((RESULT) != CPG_OK) throw Exception(errorStr((RESULT), (MSG)))
8 + if ((RESULT) != CS_OK) throw Exception(errorStr((RESULT), (MSG)))
14 // Applies the same retry-logic to all cpg calls that need it.
15 void Cpg::callCpg ( CpgOp & c ) {
18 unsigned int snooze = 10;
19 for ( unsigned int nth_try = 0; nth_try < cpgRetries; ++ nth_try ) {
20 - if ( CPG_OK == (result = c.op(handle, & group))) {
21 + if ( CS_OK == (result = c.op(handle, & group))) {
24 - else if ( result == CPG_ERR_TRY_AGAIN ) {
25 + else if ( result == CS_ERR_TRY_AGAIN ) {
26 QPID_LOG(info, "Retrying " << c.opName );
27 sys::usleep ( snooze );
30 else break; // Don't retry unless CPG tells us to.
33 - if ( result != CPG_OK )
34 + if ( result != CS_OK )
35 CPG_CHECK(result, c.msg(group));
39 callbacks.cpg_confchg_fn = &globalConfigChange;
41 QPID_LOG(notice, "Initializing CPG");
42 - cpg_error_t err = cpg_initialize(&handle, &callbacks);
43 + cs_error_t err = cpg_initialize(&handle, &callbacks);
44 int retries = 6; // FIXME aconway 2009-08-06: make this configurable.
45 - while (err == CPG_ERR_TRY_AGAIN && --retries) {
46 + while (err == CS_ERR_TRY_AGAIN && --retries) {
47 QPID_LOG(notice, "Re-trying CPG initialization.");
49 err = cpg_initialize(&handle, &callbacks);
51 if (flowState == CPG_FLOW_CONTROL_ENABLED)
57 result = cpg_mcast_joined(handle, CPG_TYPE_AGREED, const_cast<iovec*>(iov), iovLen);
58 - if (result != CPG_ERR_TRY_AGAIN) CPG_CHECK(result, cantMcastMsg(group));
59 - } while(result == CPG_ERR_TRY_AGAIN);
60 + if (result != CS_ERR_TRY_AGAIN) CPG_CHECK(result, cantMcastMsg(group));
61 + } while(result == CS_ERR_TRY_AGAIN);
68 void Cpg::dispatchOne() {
69 - CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_ONE), "Error in CPG dispatch");
70 + CPG_CHECK(cpg_dispatch(handle,CS_DISPATCH_ONE), "Error in CPG dispatch");
73 void Cpg::dispatchAll() {
74 - CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_ALL), "Error in CPG dispatch");
75 + CPG_CHECK(cpg_dispatch(handle,CS_DISPATCH_ALL), "Error in CPG dispatch");
78 void Cpg::dispatchBlocking() {
79 - CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_BLOCKING), "Error in CPG dispatch");
80 + CPG_CHECK(cpg_dispatch(handle,CS_DISPATCH_BLOCKING), "Error in CPG dispatch");
83 -string Cpg::errorStr(cpg_error_t err, const std::string& msg) {
84 +string Cpg::errorStr(cs_error_t err, const std::string& msg) {
85 std::ostringstream os;
88 - case CPG_OK: os << "ok"; break;
89 - case CPG_ERR_LIBRARY: os << "library"; break;
90 - case CPG_ERR_TIMEOUT: os << "timeout"; break;
91 - case CPG_ERR_TRY_AGAIN: os << "try again"; break;
92 - case CPG_ERR_INVALID_PARAM: os << "invalid param"; break;
93 - case CPG_ERR_NO_MEMORY: os << "no memory"; break;
94 - case CPG_ERR_BAD_HANDLE: os << "bad handle"; break;
95 - case CPG_ERR_ACCESS: os << "access denied. You may need to set your group ID to 'ais'"; break;
96 - case CPG_ERR_NOT_EXIST: os << "not exist"; break;
97 - case CPG_ERR_EXIST: os << "exist"; break;
98 - case CPG_ERR_NOT_SUPPORTED: os << "not supported"; break;
99 - case CPG_ERR_SECURITY: os << "security"; break;
100 - case CPG_ERR_TOO_MANY_GROUPS: os << "too many groups"; break;
101 + case CS_OK: os << "ok"; break;
102 + case CS_ERR_LIBRARY: os << "library"; break;
103 + case CS_ERR_TIMEOUT: os << "timeout"; break;
104 + case CS_ERR_TRY_AGAIN: os << "try again"; break;
105 + case CS_ERR_INVALID_PARAM: os << "invalid param"; break;
106 + case CS_ERR_NO_MEMORY: os << "no memory"; break;
107 + case CS_ERR_BAD_HANDLE: os << "bad handle"; break;
108 + case CS_ERR_ACCESS: os << "access denied. You may need to set your group ID to 'ais'"; break;
109 + case CS_ERR_NOT_EXIST: os << "not exist"; break;
110 + case CS_ERR_EXIST: os << "exist"; break;
111 + case CS_ERR_NOT_SUPPORTED: os << "not supported"; break;
112 + case CS_ERR_SECURITY: os << "security"; break;
113 + case CS_ERR_TOO_MANY_GROUPS: os << "too many groups"; break;
114 default: os << ": unknown cpg error " << err;
116 os << " (" << err << ")";
117 --- qpidc-0.16/src/qpid/cluster/Cpg.h.orig 2009-12-11 16:29:00.000000000 +0100
118 +++ qpidc-0.16/src/qpid/cluster/Cpg.h 2020-12-13 06:57:45.132602462 +0100
120 CpgOp ( std::string opName )
123 - virtual cpg_error_t op ( cpg_handle_t handle, struct cpg_name * ) = 0;
124 + virtual cs_error_t op ( cpg_handle_t handle, struct cpg_name * ) = 0;
125 virtual std::string msg(const Name&) = 0;
126 virtual ~CpgOp ( ) { }
130 : CpgOp ( std::string("cpg_join") ) { }
132 - cpg_error_t op(cpg_handle_t handle, struct cpg_name * group) {
133 + cs_error_t op(cpg_handle_t handle, struct cpg_name * group) {
134 return cpg_join ( handle, group );
139 : CpgOp ( std::string("cpg_leave") ) { }
141 - cpg_error_t op(cpg_handle_t handle, struct cpg_name * group) {
142 + cs_error_t op(cpg_handle_t handle, struct cpg_name * group) {
143 return cpg_leave ( handle, group );
148 : CpgOp ( std::string("cpg_finalize") ) { }
150 - cpg_error_t op(cpg_handle_t handle, struct cpg_name *) {
151 + cs_error_t op(cpg_handle_t handle, struct cpg_name *) {
152 return cpg_finalize ( handle );
156 CpgLeaveOp cpgLeaveOp;
157 CpgFinalizeOp cpgFinalizeOp;
159 - static std::string errorStr(cpg_error_t err, const std::string& msg);
160 + static std::string errorStr(cs_error_t err, const std::string& msg);
161 static std::string cantJoinMsg(const Name&);
162 static std::string cantLeaveMsg(const Name&);
163 static std::string cantMcastMsg(const Name&);