summaryrefslogtreecommitdiff
path: root/examples/amqp_producer.c
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2013-07-03 12:35:27 -0700
committerAlan Antonuk <alan.antonuk@gmail.com>2013-07-03 12:35:27 -0700
commitda9c2c109ad9740177adfc93e5e92cba92c56134 (patch)
treef89f2512aea79d7abb64aa1f7900057eae44f8c4 /examples/amqp_producer.c
parent448ab68ac6299b73f6ccd697949d2d566d5a1a64 (diff)
downloadrabbitmq-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 'examples/amqp_producer.c')
-rw-r--r--examples/amqp_producer.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/examples/amqp_producer.c b/examples/amqp_producer.c
index efa1a20..948d8f6 100644
--- a/examples/amqp_producer.c
+++ b/examples/amqp_producer.c
@@ -130,7 +130,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");
}
@@ -140,7 +140,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);