diff options
| author | Gordon Sim <gsim@apache.org> | 2014-05-13 16:46:01 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2014-05-13 16:46:01 +0000 |
| commit | 297b63fd0fdde764dc1c9aa7da7d9d7a0a5d1283 (patch) | |
| tree | 8dce09918bad44ed12750843e35c9f8e26d81bb4 /qpid/cpp/src | |
| parent | 8a960df8b0b42f07e0469db315f7283278fc2f1a (diff) | |
| download | qpid-python-297b63fd0fdde764dc1c9aa7da7d9d7a0a5d1283.tar.gz | |
QPID-5747: create codec for outgoing connections on establishing the connection, so that any disconnect before we try to write can still be communicated to upper layers
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1594277 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp | 29 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/sys/AsynchIOHandler.h | 1 |
2 files changed, 18 insertions, 12 deletions
diff --git a/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp b/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp index 243e3d4603..bb59530883 100644 --- a/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp +++ b/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp @@ -58,7 +58,8 @@ AsynchIOHandler::AsynchIOHandler(const std::string& id, ConnectionCodec::Factory codec(0), readError(false), isClient(isClient0), - nodict(nodict0) + nodict(nodict0), + headerSent(false) {} AsynchIOHandler::~AsynchIOHandler() { @@ -69,6 +70,15 @@ AsynchIOHandler::~AsynchIOHandler() { delete codec; } +namespace { + SecuritySettings getSecuritySettings(AsynchIO* aio, bool nodict) + { + SecuritySettings settings = aio->getSecuritySettings(); + settings.nodict = nodict; + return settings; + } +} + void AsynchIOHandler::init(qpid::sys::AsynchIO* a, qpid::sys::Timer& timer, uint32_t maxTime) { aio = a; @@ -78,6 +88,10 @@ void AsynchIOHandler::init(qpid::sys::AsynchIO* a, qpid::sys::Timer& timer, uint // Give connection some buffers to use aio->createBuffers(); + + if (isClient) { + codec = factory->create(*this, identifier, getSecuritySettings(aio, nodict)); + } } void AsynchIOHandler::write(const framing::ProtocolInitiation& data) @@ -110,15 +124,6 @@ void AsynchIOHandler::activateOutput() { aio->notifyPendingWrite(); } -namespace { - SecuritySettings getSecuritySettings(AsynchIO* aio, bool nodict) - { - SecuritySettings settings = aio->getSecuritySettings(); - settings.nodict = nodict; - return settings; - } -} - void AsynchIOHandler::readbuff(AsynchIO& , AsynchIO::BufferBase* buff) { if (readError) { return; @@ -198,9 +203,9 @@ void AsynchIOHandler::nobuffs(AsynchIO&) { } void AsynchIOHandler::idle(AsynchIO&){ - if (isClient && codec == 0) { - codec = factory->create(*this, identifier, getSecuritySettings(aio, nodict)); + if (isClient && !headerSent) { write(framing::ProtocolInitiation(codec->getVersion())); + headerSent = true; return; } if (codec == 0) return; diff --git a/qpid/cpp/src/qpid/sys/AsynchIOHandler.h b/qpid/cpp/src/qpid/sys/AsynchIOHandler.h index 2dc15c1a19..698ac5fc9c 100644 --- a/qpid/cpp/src/qpid/sys/AsynchIOHandler.h +++ b/qpid/cpp/src/qpid/sys/AsynchIOHandler.h @@ -51,6 +51,7 @@ class AsynchIOHandler : public OutputControl { bool readError; bool isClient; bool nodict; + bool headerSent; boost::intrusive_ptr<sys::TimerTask> timeoutTimerTask; void write(const framing::ProtocolInitiation&); |
