From da9c2c109ad9740177adfc93e5e92cba92c56134 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Wed, 3 Jul 2013 12:35:27 -0700 Subject: 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 --- examples/amqp_unbind.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples/amqp_unbind.c') diff --git a/examples/amqp_unbind.c b/examples/amqp_unbind.c index 7948d0b..1ca3e83 100644 --- a/examples/amqp_unbind.c +++ b/examples/amqp_unbind.c @@ -68,7 +68,7 @@ int main(int argc, char const *const *argv) conn = amqp_new_connection(); - socket = amqp_tcp_socket_new(); + socket = amqp_tcp_socket_new(conn); if (!socket) { die("creating TCP socket"); } @@ -78,7 +78,6 @@ int main(int argc, char const *const *argv) die("opening TCP socket"); } - amqp_set_socket(conn, socket); die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), "Logging in"); amqp_channel_open(conn, 1); -- cgit v1.2.1