Author: gsim
Date: Tue May 13 16:46:01 2014
New Revision: 1594277

URL: http://svn.apache.org/r1594277
Log:
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

Modified:
    qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp?rev=1594277&r1=1594276&r2=1594277&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.cpp Tue May 13 16:46:01 
2014
@@ -58,7 +58,8 @@ AsynchIOHandler::AsynchIOHandler(const s
     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::As
 
     // 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;

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h?rev=1594277&r1=1594276&r2=1594277&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/AsynchIOHandler.h Tue May 13 16:46:01 2014
@@ -51,6 +51,7 @@ class AsynchIOHandler : public OutputCon
     bool readError;
     bool isClient;
     bool nodict;
+    bool headerSent;
     boost::intrusive_ptr<sys::TimerTask> timeoutTimerTask;
 
     void write(const framing::ProtocolInitiation&);



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to