summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/src/qpid/client/TCPConnector.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/cpp/src/qpid/client/TCPConnector.cpp b/cpp/src/qpid/client/TCPConnector.cpp
index 94c4a4cae0..78c9b32069 100644
--- a/cpp/src/qpid/client/TCPConnector.cpp
+++ b/cpp/src/qpid/client/TCPConnector.cpp
@@ -139,8 +139,8 @@ void TCPConnector::connectFailed(const std::string& msg) {
bool TCPConnector::closeInternal() {
Mutex::ScopedLock l(lock);
bool ret = !closed;
- if (!closed) {
- closed = true;
+ closed = true;
+ if (ret) {
if (aio)
aio->queueForDeletion();
socket.close();
@@ -186,18 +186,20 @@ const std::string& TCPConnector::getIdentifier() const {
}
void TCPConnector::send(AMQFrame& frame) {
+ bool notifyWrite = false;
+ {
Mutex::ScopedLock l(lock);
frames.push_back(frame);
//only ask to write if this is the end of a frameset or if we
//already have a buffers worth of data
currentSize += frame.encodedSize();
- bool notifyWrite = false;
if (frame.getEof()) {
lastEof = frames.size();
notifyWrite = true;
} else {
notifyWrite = (currentSize >= maxFrameSize);
}
+ }
if (notifyWrite && !closed) aio->notifyPendingWrite();
}