From f1ba7709347e5282438dbec5bed5e55c861092cd Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 31 Jan 2008 18:50:46 +0000 Subject: Make ports accesible through socket interface. Add local port to each logged frame in the client Connector git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@617188 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/Connector.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'cpp/src/qpid/client/Connector.cpp') diff --git a/cpp/src/qpid/client/Connector.cpp b/cpp/src/qpid/client/Connector.cpp index f13649a24e..a0be05fbbc 100644 --- a/cpp/src/qpid/client/Connector.cpp +++ b/cpp/src/qpid/client/Connector.cpp @@ -29,12 +29,15 @@ #include "qpid/sys/Poller.h" #include "qpid/Msg.h" #include +#include namespace qpid { namespace client { using namespace qpid::sys; using namespace qpid::framing; +using boost::format; +using boost::str; Connector::Connector( ProtocolVersion ver, bool _debug, uint32_t buffer_size @@ -59,7 +62,7 @@ void Connector::connect(const std::string& host, int port){ Mutex::ScopedLock l(closedLock); assert(closed); socket.connect(host, port); - identifier=socket.getPeerAddress(); + identifier=str(format("[%1% %2%]") % socket.getLocalPort() % socket.getPeerAddress()); closed = false; poller = Poller::shared_ptr(new Poller); aio = new AsynchIO(socket, @@ -175,7 +178,9 @@ struct Connector::Buff : public AsynchIO::BufferBase { ~Buff() { delete [] bytes;} }; -Connector::Writer::Writer() : aio(0), buffer(0), lastEof(0) {} +Connector::Writer::Writer() : aio(0), buffer(0), lastEof(0) +{ +} Connector::Writer::~Writer() { delete buffer; } @@ -183,6 +188,7 @@ void Connector::Writer::setAio(sys::AsynchIO* a) { Mutex::ScopedLock l(lock); aio = a; newBuffer(l); + identifier = str(format("[%1% %2%]") % aio->getSocket().getLocalPort() % aio->getSocket().getPeerAddress()); } void Connector::Writer::handle(framing::AMQFrame& frame) { @@ -192,7 +198,7 @@ void Connector::Writer::handle(framing::AMQFrame& frame) { lastEof = frames.size(); aio->notifyPendingWrite(); } - QPID_LOG(trace, "SENT (" << aio->getSocket().getPeerAddress() << "): " << frame); + QPID_LOG(trace, "SENT " << identifier << ": " << frame); } void Connector::Writer::writeOne(const Mutex::ScopedLock& l) { @@ -235,7 +241,7 @@ void Connector::readbuff(AsynchIO& aio, AsynchIO::BufferBase* buff) { AMQFrame frame; while(frame.decode(in)){ - QPID_LOG(trace, "RECV (" << identifier << "): " << frame); + QPID_LOG(trace, "RECV " << identifier << ": " << frame); input->received(frame); } // TODO: unreading needs to go away, and when we can cope -- cgit v1.2.1