Author: gsim
Date: Mon Aug 13 02:41:45 2007
New Revision: 565284
URL: http://svn.apache.org/viewvc?view=rev&rev=565284
Log:
Fixes for QPID-544 and QPID-548
Modified:
incubator/qpid/branches/M2/cpp/lib/broker/SessionHandlerImpl.cpp
incubator/qpid/branches/M2/cpp/lib/client/Connection.cpp
incubator/qpid/branches/M2/cpp/lib/client/Connection.h
incubator/qpid/branches/M2/cpp/lib/client/Connector.cpp
incubator/qpid/branches/M2/cpp/lib/client/Connector.h
incubator/qpid/branches/M2/cpp/lib/common/sys/Socket.h
incubator/qpid/branches/M2/cpp/lib/common/sys/apr/Socket.cpp
incubator/qpid/branches/M2/cpp/lib/common/sys/posix/Socket.cpp
incubator/qpid/branches/M2/cpp/tests/client_test.cpp
Modified: incubator/qpid/branches/M2/cpp/lib/broker/SessionHandlerImpl.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/lib/broker/SessionHandlerImpl.cpp?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/lib/broker/SessionHandlerImpl.cpp (original)
+++ incubator/qpid/branches/M2/cpp/lib/broker/SessionHandlerImpl.cpp Mon Aug 13
02:41:45 2007
@@ -298,7 +298,6 @@
queue = queue_created.first;
assert(queue);
if (queue_created.second) { // This is a new queue
- parent->getChannel(channel)->setDefaultQueue(queue);
//apply settings & create persistent record if required
queue_created.first->create(arguments);
@@ -315,6 +314,7 @@
if (exclusive && !queue->isExclusiveOwner(parent)) {
throw ChannelException(405, "Cannot grant exclusive access to queue");
}
+ parent->getChannel(channel)->setDefaultQueue(queue);
if (!nowait) {
string queueName = queue->getName();
parent->client->getQueue().declareOk(channel, queueName,
queue->getMessageCount(), queue->getConsumerCount());
Modified: incubator/qpid/branches/M2/cpp/lib/client/Connection.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/lib/client/Connection.cpp?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/lib/client/Connection.cpp (original)
+++ incubator/qpid/branches/M2/cpp/lib/client/Connection.cpp Mon Aug 13
02:41:45 2007
@@ -35,7 +35,8 @@
channelIdCounter(0),
max_frame_size(_max_frame_size),
closed(true),
- version(_version->getMajor(),_version->getMinor())
+ version(_version->getMajor(),_version->getMinor()),
+ tcpNoDelay(false)
{
connector = new Connector(version, debug, _max_frame_size);
}
@@ -44,6 +45,10 @@
delete connector;
}
+void Connection::setTcpNoDelay(bool on) {
+ tcpNoDelay = on;
+}
+
void Connection::open(const std::string& _host, int _port, const std::string&
uid, const std::string& pwd, const std::string& virtualhost){
host = _host;
port = _port;
@@ -51,7 +56,7 @@
connector->setTimeoutHandler(this);
connector->setShutdownHandler(this);
out = connector->getOutputHandler();
- connector->connect(host, port);
+ connector->connect(host, port, tcpNoDelay);
ProtocolInitiation* header = new ProtocolInitiation(version);
responses.expect();
Modified: incubator/qpid/branches/M2/cpp/lib/client/Connection.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/lib/client/Connection.h?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/lib/client/Connection.h (original)
+++ incubator/qpid/branches/M2/cpp/lib/client/Connection.h Mon Aug 13 02:41:45
2007
@@ -80,6 +80,7 @@
ResponseHandler responses;
volatile bool closed;
qpid::framing::ProtocolVersion version;
+ bool tcpNoDelay;
void channelException(Channel* channel, qpid::framing::AMQMethodBody*
body, QpidError& e);
void error(int code, const std::string& msg, int classid = 0, int
methodid = 0);
@@ -108,6 +109,8 @@
Connection( bool debug = false, u_int32_t max_frame_size = 65536,
qpid::framing::ProtocolVersion* _version =
&(qpid::framing::highestProtocolVersion));
~Connection();
+
+ void setTcpNoDelay(bool on);
/**
* Opens a connection to a broker.
Modified: incubator/qpid/branches/M2/cpp/lib/client/Connector.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/lib/client/Connector.cpp?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/lib/client/Connector.cpp (original)
+++ incubator/qpid/branches/M2/cpp/lib/client/Connector.cpp Mon Aug 13 02:41:45
2007
@@ -44,8 +44,11 @@
Connector::~Connector(){ }
-void Connector::connect(const std::string& host, int port){
+void Connector::connect(const std::string& host, int port, bool tcpNoDelay){
socket = Socket::createTcp();
+ if (tcpNoDelay) {
+ socket.setTcpNoDelay(true);
+ }
socket.connect(host, port);
closed = false;
receiver = Thread(this);
Modified: incubator/qpid/branches/M2/cpp/lib/client/Connector.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/lib/client/Connector.h?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/lib/client/Connector.h (original)
+++ incubator/qpid/branches/M2/cpp/lib/client/Connector.h Mon Aug 13 02:41:45
2007
@@ -78,7 +78,7 @@
public:
Connector(const qpid::framing::ProtocolVersion& pVersion, bool debug =
false, u_int32_t buffer_size = 1024);
virtual ~Connector();
- virtual void connect(const std::string& host, int port);
+ virtual void connect(const std::string& host, int port, bool
tcpNoDelay=false);
virtual void init(qpid::framing::ProtocolInitiation* header);
virtual void close();
virtual void setInputHandler(qpid::framing::InputHandler* handler);
Modified: incubator/qpid/branches/M2/cpp/lib/common/sys/Socket.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/lib/common/sys/Socket.h?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/lib/common/sys/Socket.h (original)
+++ incubator/qpid/branches/M2/cpp/lib/common/sys/Socket.h Mon Aug 13 02:41:45
2007
@@ -47,6 +47,7 @@
/** Set timeout for read and write */
void setTimeout(Time interval);
+ void setTcpNoDelay(bool on);
void connect(const std::string& host, int port);
Modified: incubator/qpid/branches/M2/cpp/lib/common/sys/apr/Socket.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/lib/common/sys/apr/Socket.cpp?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/lib/common/sys/apr/Socket.cpp (original)
+++ incubator/qpid/branches/M2/cpp/lib/common/sys/apr/Socket.cpp Mon Aug 13
02:41:45 2007
@@ -87,4 +87,8 @@
return received;
}
+void Socket::setTcpNoDelay(bool on)
+{
+ CHECK_APR_SUCCESS(apr_socket_opt_set(socket, APR_TCP_NODELAY, on ? 1 : 0));
+}
Modified: incubator/qpid/branches/M2/cpp/lib/common/sys/posix/Socket.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/lib/common/sys/posix/Socket.cpp?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/lib/common/sys/posix/Socket.cpp (original)
+++ incubator/qpid/branches/M2/cpp/lib/common/sys/posix/Socket.cpp Mon Aug 13
02:41:45 2007
@@ -116,3 +116,5 @@
{
return socket;
}
+
+void Socket::setTcpNoDelay(bool) {} //not yet implemented
Modified: incubator/qpid/branches/M2/cpp/tests/client_test.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/cpp/tests/client_test.cpp?view=diff&rev=565284&r1=565283&r2=565284
==============================================================================
--- incubator/qpid/branches/M2/cpp/tests/client_test.cpp (original)
+++ incubator/qpid/branches/M2/cpp/tests/client_test.cpp Mon Aug 13 02:41:45
2007
@@ -67,6 +67,7 @@
Connection con(argc > 1);
+ con.setTcpNoDelay(true);
string host("localhost");
con.open(host, 5672, "guest", "guest", "/test");
std::cout << "Opened connection." << std::endl;