You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2009/07/21 17:05:51 UTC
svn commit: r796333 - in /qpid/trunk/qpid/cpp/src/qpid:
broker/SemanticState.cpp broker/SessionAdapter.cpp cluster/Cpg.cpp
cluster/Cpg.h
Author: aconway
Date: Tue Jul 21 15:05:51 2009
New Revision: 796333
URL: http://svn.apache.org/viewvc?rev=796333&view=rev
Log:
Remove some unnecessary promotions of char* to std::string.
Modified:
qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp
qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.cpp
qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.h
Modified: qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp?rev=796333&r1=796332&r2=796333&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp Tue Jul 21 15:05:51 2009
@@ -228,6 +228,8 @@
unacked.push_back(delivery);
}
+const std::string QPID_SYNC_FREQUENCY("qpid.sync_frequency");
+
SemanticState::ConsumerImpl::ConsumerImpl(SemanticState* _parent,
const string& _name,
Queue::shared_ptr _queue,
@@ -255,7 +257,7 @@
msgCredit(0),
byteCredit(0),
notifyEnabled(true),
- syncFrequency(_arguments.getAsInt("qpid.sync_frequency")),
+ syncFrequency(_arguments.getAsInt(QPID_SYNC_FREQUENCY)),
deliveryCount(0)
{}
Modified: qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp?rev=796333&r1=796332&r2=796333&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp Tue Jul 21 15:05:51 2009
@@ -57,6 +57,8 @@
dtxImpl(s)
{}
+static const std::string TRUE("true");
+static const std::string FALSE("false");
void SessionAdapter::ExchangeHandlerImpl::declare(const string& exchange, const string& type,
const string& alternateExchange,
@@ -67,8 +69,8 @@
std::map<acl::Property, std::string> params;
params.insert(make_pair(acl::PROP_TYPE, type));
params.insert(make_pair(acl::PROP_ALTERNATE, alternateExchange));
- params.insert(make_pair(acl::PROP_PASSIVE, std::string(passive ? "true" : "false") ));
- params.insert(make_pair(acl::PROP_DURABLE, std::string(durable ? "true" : "false")));
+ params.insert(make_pair(acl::PROP_PASSIVE, std::string(passive ? TRUE : FALSE) ));
+ params.insert(make_pair(acl::PROP_DURABLE, std::string(durable ? TRUE : FALSE)));
if (!acl->authorise(getConnection().getUserId(),acl::ACT_CREATE,acl::OBJ_EXCHANGE,exchange,¶ms) )
throw NotAllowedException(QPID_MSG("ACL denied exhange declare request from " << getConnection().getUserId()));
}
@@ -325,10 +327,10 @@
if (acl) {
std::map<acl::Property, std::string> params;
params.insert(make_pair(acl::PROP_ALTERNATE, alternateExchange));
- params.insert(make_pair(acl::PROP_PASSIVE, std::string(passive ? "true" : "false") ));
- params.insert(make_pair(acl::PROP_DURABLE, std::string(durable ? "true" : "false")));
- params.insert(make_pair(acl::PROP_EXCLUSIVE, std::string(exclusive ? "true" : "false")));
- params.insert(make_pair(acl::PROP_AUTODELETE, std::string(autoDelete ? "true" : "false")));
+ params.insert(make_pair(acl::PROP_PASSIVE, std::string(passive ? TRUE : FALSE) ));
+ params.insert(make_pair(acl::PROP_DURABLE, std::string(durable ? TRUE : FALSE)));
+ params.insert(make_pair(acl::PROP_EXCLUSIVE, std::string(exclusive ? TRUE : FALSE)));
+ params.insert(make_pair(acl::PROP_AUTODELETE, std::string(autoDelete ? TRUE : FALSE)));
if (!acl->authorise(getConnection().getUserId(),acl::ACT_CREATE,acl::OBJ_QUEUE,name,¶ms) )
throw NotAllowedException(QPID_MSG("ACL denied queue create request from " << getConnection().getUserId()));
}
Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.cpp?rev=796333&r1=796332&r2=796333&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.cpp Tue Jul 21 15:05:51 2009
@@ -29,6 +29,11 @@
#include <unistd.h>
+// 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)))
+
namespace qpid {
namespace cluster {
@@ -36,7 +41,7 @@
Cpg* Cpg::cpgFromHandle(cpg_handle_t handle) {
void* cpg=0;
- check(cpg_context_get(handle, &cpg), "Cannot get CPG instance.");
+ CPG_CHECK(cpg_context_get(handle, &cpg), "Cannot get CPG instance.");
if (!cpg) throw Exception("Cannot get CPG instance.");
return reinterpret_cast<Cpg*>(cpg);
}
@@ -66,7 +71,7 @@
int Cpg::getFd() {
int fd;
- check(cpg_fd_get(handle, &fd), "Cannot get CPG file descriptor");
+ CPG_CHECK(cpg_fd_get(handle, &fd), "Cannot get CPG file descriptor");
return fd;
}
@@ -84,8 +89,8 @@
sys::sleep(5);
err = cpg_initialize(&handle, &callbacks);
}
- check(err, "Failed to initialize CPG.");
- check(cpg_context_set(handle, this), "Cannot set CPG context");
+ CPG_CHECK(err, "Failed to initialize CPG.");
+ CPG_CHECK(cpg_context_set(handle, this), "Cannot set CPG context");
// Note: CPG is currently unix-specific. If CPG is ported to
// windows then this needs to be refactored into
// qpid::sys::<platform>
@@ -102,11 +107,11 @@
void Cpg::join(const std::string& name) {
group = name;
- check(cpg_join(handle, &group), cantJoinMsg(group));
+ CPG_CHECK(cpg_join(handle, &group), cantJoinMsg(group));
}
void Cpg::leave() {
- check(cpg_leave(handle, &group), cantLeaveMsg(group));
+ CPG_CHECK(cpg_leave(handle, &group), cantLeaveMsg(group));
}
@@ -115,14 +120,14 @@
bool Cpg::mcast(const iovec* iov, int iovLen) {
// Check for flow control
cpg_flow_control_state_t flowState;
- check(cpg_flow_control_state_get(handle, &flowState), "Cannot get CPG flow control status.");
+ CPG_CHECK(cpg_flow_control_state_get(handle, &flowState), "Cannot get CPG flow control status.");
if (flowState == CPG_FLOW_CONTROL_ENABLED)
return false;
cpg_error_t result;
do {
result = cpg_mcast_joined(handle, CPG_TYPE_AGREED, const_cast<iovec*>(iov), iovLen);
- if (result != CPG_ERR_TRY_AGAIN) check(result, cantMcastMsg(group));
+ if (result != CPG_ERR_TRY_AGAIN) CPG_CHECK(result, cantMcastMsg(group));
} while(result == CPG_ERR_TRY_AGAIN);
return true;
}
@@ -131,20 +136,20 @@
if (!isShutdown) {
QPID_LOG(debug,"Shutting down CPG");
isShutdown=true;
- check(cpg_finalize(handle), "Error in shutdown of CPG");
+ CPG_CHECK(cpg_finalize(handle), "Error in shutdown of CPG");
}
}
void Cpg::dispatchOne() {
- check(cpg_dispatch(handle,CPG_DISPATCH_ONE), "Error in CPG dispatch");
+ CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_ONE), "Error in CPG dispatch");
}
void Cpg::dispatchAll() {
- check(cpg_dispatch(handle,CPG_DISPATCH_ALL), "Error in CPG dispatch");
+ CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_ALL), "Error in CPG dispatch");
}
void Cpg::dispatchBlocking() {
- check(cpg_dispatch(handle,CPG_DISPATCH_BLOCKING), "Error in CPG dispatch");
+ CPG_CHECK(cpg_dispatch(handle,CPG_DISPATCH_BLOCKING), "Error in CPG dispatch");
}
string Cpg::errorStr(cpg_error_t err, const std::string& msg) {
@@ -184,7 +189,7 @@
MemberId Cpg::self() const {
unsigned int nodeid;
- check(cpg_local_get(handle, &nodeid), "Cannot get local CPG identity");
+ CPG_CHECK(cpg_local_get(handle, &nodeid), "Cannot get local CPG identity");
return MemberId(nodeid, getpid());
}
Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.h?rev=796333&r1=796332&r2=796333&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Cpg.h Tue Jul 21 15:05:51 2009
@@ -120,10 +120,6 @@
static std::string cantLeaveMsg(const Name&);
static std::string cantMcastMsg(const Name&);
- static void check(cpg_error_t result, const std::string& msg) {
- if (result != CPG_OK) throw Exception(errorStr(result, msg));
- }
-
static Cpg* cpgFromHandle(cpg_handle_t);
static void globalDeliver(
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org