summaryrefslogtreecommitdiff
path: root/cpp/lib/client
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/lib/client')
-rw-r--r--cpp/lib/client/Connection.cpp1
-rw-r--r--cpp/lib/client/ResponseHandler.cpp14
2 files changed, 8 insertions, 7 deletions
diff --git a/cpp/lib/client/Connection.cpp b/cpp/lib/client/Connection.cpp
index 10a0b50aad..dd1e372095 100644
--- a/cpp/lib/client/Connection.cpp
+++ b/cpp/lib/client/Connection.cpp
@@ -253,4 +253,5 @@ void Connection::shutdown(){
for(iterator i = channels.begin(); i != channels.end(); i++){
i->second->stop();
}
+ responses.signalResponse(AMQMethodBody::shared_ptr());
}
diff --git a/cpp/lib/client/ResponseHandler.cpp b/cpp/lib/client/ResponseHandler.cpp
index ac8b4a9ced..68c7e52013 100644
--- a/cpp/lib/client/ResponseHandler.cpp
+++ b/cpp/lib/client/ResponseHandler.cpp
@@ -29,28 +29,28 @@ qpid::client::ResponseHandler::ResponseHandler() : waiting(false){}
qpid::client::ResponseHandler::~ResponseHandler(){}
bool qpid::client::ResponseHandler::validate(const qpid::framing::AMQMethodBody& expected){
- return expected.match(response.get());
+ return response != 0 && expected.match(response.get());
}
void qpid::client::ResponseHandler::waitForResponse(){
Monitor::ScopedLock l(monitor);
- if(waiting){
+ while (waiting)
monitor.wait();
- }
}
-void qpid::client::ResponseHandler::signalResponse(qpid::framing::AMQMethodBody::shared_ptr _response){
- response = _response;
+void qpid::client::ResponseHandler::signalResponse(
+ qpid::framing::AMQMethodBody::shared_ptr _response)
+{
Monitor::ScopedLock l(monitor);
+ response = _response;
waiting = false;
monitor.notify();
}
void qpid::client::ResponseHandler::receive(const qpid::framing::AMQMethodBody& expected){
Monitor::ScopedLock l(monitor);
- if(waiting){
+ while (waiting)
monitor.wait();
- }
if(!validate(expected)){
THROW_QPID_ERROR(PROTOCOL_ERROR, "Protocol Error");
}