diff options
author | Gordon Sim <gsim@apache.org> | 2010-03-19 17:04:18 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2010-03-19 17:04:18 +0000 |
commit | 45b5d1cc1f48ed8f6caef8ee9652f788d69747a5 (patch) | |
tree | 285eebffee4dd1252abde2dd39872531565987d3 /cpp/examples/messaging/queue_receiver.cpp | |
parent | d6de561675087e8b1a6978d82569467c4aeff398 (diff) | |
download | qpid-python-45b5d1cc1f48ed8f6caef8ee9652f788d69747a5.tar.gz |
QPID-664: Prevent dangling pointers when receiver/sender handles stay in scope after connection/session handles goes out of scope. This change require connections to be closed explicitly to avoid leaking memory.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@925332 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/examples/messaging/queue_receiver.cpp')
-rw-r--r-- | cpp/examples/messaging/queue_receiver.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/cpp/examples/messaging/queue_receiver.cpp b/cpp/examples/messaging/queue_receiver.cpp index 192b90088d..95756a9a3d 100644 --- a/cpp/examples/messaging/queue_receiver.cpp +++ b/cpp/examples/messaging/queue_receiver.cpp @@ -31,8 +31,8 @@ using namespace qpid::messaging; int main(int argc, char** argv) { const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + Connection connection; try { - Connection connection; connection.open(url); Session session = connection.newSession(); Receiver receiver = session.createReceiver("message_queue"); @@ -51,6 +51,7 @@ int main(int argc, char** argv) { return 0; } catch(const std::exception& error) { std::cout << error.what() << std::endl; + connection.close(); } return 1; } |