diff options
Diffstat (limited to 'examples/amqp_listen.c')
-rw-r--r-- | examples/amqp_listen.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/amqp_listen.c b/examples/amqp_listen.c index 448ced1..f208652 100644 --- a/examples/amqp_listen.c +++ b/examples/amqp_listen.c @@ -51,7 +51,6 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#include <errno.h> #include <stdint.h> #include <amqp.h> @@ -101,7 +100,8 @@ int main(int argc, char const * const *argv) { die_on_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue"); queuename = amqp_bytes_malloc_dup(r->queue); if (queuename.bytes == NULL) { - die_on_error(-ENOMEM, "Copying queue name"); + fprintf(stderr, "Out of memory while copying queue name"); + return 1; } } @@ -125,7 +125,7 @@ int main(int argc, char const * const *argv) { amqp_maybe_release_buffers(conn); result = amqp_simple_wait_frame(conn, &frame); printf("Result %d\n", result); - if (result <= 0) + if (result < 0) break; printf("Frame type %d, channel %d\n", frame.frame_type, frame.channel); @@ -143,7 +143,7 @@ int main(int argc, char const * const *argv) { (int) d->routing_key.len, (char *) d->routing_key.bytes); result = amqp_simple_wait_frame(conn, &frame); - if (result <= 0) + if (result < 0) break; if (frame.frame_type != AMQP_FRAME_HEADER) { @@ -162,7 +162,7 @@ int main(int argc, char const * const *argv) { while (body_received < body_target) { result = amqp_simple_wait_frame(conn, &frame); - if (result <= 0) + if (result < 0) break; if (frame.frame_type != AMQP_FRAME_BODY) { @@ -187,8 +187,7 @@ int main(int argc, char const * const *argv) { die_on_amqp_error(amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS), "Closing channel"); die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS), "Closing connection"); - amqp_destroy_connection(conn); - die_on_error(close(sockfd), "Closing socket"); + die_on_error(amqp_destroy_connection(conn), "Ending connection"); return 0; } |