diff options
author | Alan Antonuk <alan.antonuk@gmail.com> | 2013-07-03 12:35:27 -0700 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2013-07-03 12:35:27 -0700 |
commit | da9c2c109ad9740177adfc93e5e92cba92c56134 (patch) | |
tree | f89f2512aea79d7abb64aa1f7900057eae44f8c4 /tools | |
parent | 448ab68ac6299b73f6ccd697949d2d566d5a1a64 (diff) | |
download | rabbitmq-c-github-ask-da9c2c109ad9740177adfc93e5e92cba92c56134.tar.gz |
Make connection the socket object owner
Improve the socket interface by making the amqp_connection_state_t
object the amqp_socket_t owner, and tie its lifetime to the connection's
lifetime. This prevents a class of silly errors where the socket object
isn't freed, or the socket object is assigned to two different
connection objects
Diffstat (limited to 'tools')
-rw-r--r-- | tools/common.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/tools/common.c b/tools/common.c index a624105..06b41a9 100644 --- a/tools/common.c +++ b/tools/common.c @@ -332,7 +332,7 @@ amqp_connection_state_t make_connection(void) conn = amqp_new_connection(); if (ci.ssl) { #ifdef WITH_SSL - socket = amqp_ssl_socket_new(); + socket = amqp_ssl_socket_new(conn); if (!socket) { die("creating SSL/TLS socket"); } @@ -346,7 +346,7 @@ amqp_connection_state_t make_connection(void) die("librabbitmq was not built with SSL/TLS support"); #endif } else { - socket = amqp_tcp_socket_new(); + socket = amqp_tcp_socket_new(conn); if (!socket) { die("creating TCP socket (out of memory)"); } @@ -355,7 +355,6 @@ amqp_connection_state_t make_connection(void) if (status) { die("opening socket to %s:%d", ci.host, ci.port); } - amqp_set_socket(conn, socket); die_rpc(amqp_login(conn, ci.vhost, 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, ci.user, ci.password), |