QPID-3394: merge fix from trunk

git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.12@1154981 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/qpid/cpp/src/qpid/broker/SessionState.cpp b/qpid/cpp/src/qpid/broker/SessionState.cpp
index ee96469..742dbe9 100644
--- a/qpid/cpp/src/qpid/broker/SessionState.cpp
+++ b/qpid/cpp/src/qpid/broker/SessionState.cpp
@@ -445,8 +445,6 @@
 boost::intrusive_ptr<AsyncCompletion::Callback>
 SessionState::IncompleteIngressMsgXfer::clone()
 {
-    boost::intrusive_ptr<SessionState::IncompleteIngressMsgXfer> cb(new SessionState::IncompleteIngressMsgXfer(session, msg));
-
     // Optimization: this routine is *only* invoked when the message needs to be asynchronously completed.
     // If the client is pending the message.transfer completion, flush now to force immediate write to journal.
     if (requiresSync)
@@ -457,7 +455,8 @@
         pending = true;
         completerContext->addPendingMessage(msg);
     }
-    return cb;
+
+    return boost::intrusive_ptr<SessionState::IncompleteIngressMsgXfer>(new SessionState::IncompleteIngressMsgXfer(*this));
 }
 
 
diff --git a/qpid/cpp/src/qpid/broker/SessionState.h b/qpid/cpp/src/qpid/broker/SessionState.h
index b43df0c..506af85 100644
--- a/qpid/cpp/src/qpid/broker/SessionState.h
+++ b/qpid/cpp/src/qpid/broker/SessionState.h
@@ -256,7 +256,15 @@
           requiresAccept(m->requiresAccept()),
           requiresSync(m->getFrames().getMethod()->isSync()),
           pending(false) {}
-        virtual ~IncompleteIngressMsgXfer() {};
+        IncompleteIngressMsgXfer( const IncompleteIngressMsgXfer& x )
+          : AsyncCommandContext(x.session, x.msg->getCommandId()),
+          session(x.session),
+          msg(x.msg),
+          requiresAccept(x.requiresAccept),
+          requiresSync(x.requiresSync),
+          pending(x.pending) {}
+
+  virtual ~IncompleteIngressMsgXfer() {};
 
         virtual void completed(bool);
         virtual boost::intrusive_ptr<AsyncCompletion::Callback> clone();