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 | fe703fd7a9d1ae401bdf378def92ae2925a91fbc (patch) | |
| tree | 285eebffee4dd1252abde2dd39872531565987d3 /cpp/examples/messaging/drain.cpp | |
| parent | fe81d465643f4b1f47511788edbbc64bf60085f1 (diff) | |
| download | qpid-python-fe703fd7a9d1ae401bdf378def92ae2925a91fbc.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/drain.cpp')
| -rw-r--r-- | cpp/examples/messaging/drain.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/cpp/examples/messaging/drain.cpp b/cpp/examples/messaging/drain.cpp index bd18fd3884..38f6bdbb98 100644 --- a/cpp/examples/messaging/drain.cpp +++ b/cpp/examples/messaging/drain.cpp @@ -93,8 +93,8 @@ int main(int argc, char** argv) { Options options(argv[0]); if (options.parse(argc, argv)) { + Connection connection(options.connectionOptions); try { - Connection connection(options.connectionOptions); connection.open(options.url); Session session = connection.newSession(); Receiver receiver = session.createReceiver(options.address); @@ -116,6 +116,7 @@ int main(int argc, char** argv) return 0; } catch(const std::exception& error) { std::cout << error.what() << std::endl; + connection.close(); } } return 1; |
