diff options
author | David Wragg <dpw@lshift.net> | 2010-05-30 23:31:40 +0100 |
---|---|---|
committer | David Wragg <dpw@lshift.net> | 2010-05-30 23:31:40 +0100 |
commit | 2347dc9977d3bf0c9ed19f7ed3a905eb4e65fa46 (patch) | |
tree | 56b6486c279997736c61a5b3fe6661caadb7d352 /librabbitmq | |
parent | 76e825b388c6c3b65ef238a245748f38d3f1c1fc (diff) | |
download | rabbitmq-c-github-ask-2347dc9977d3bf0c9ed19f7ed3a905eb4e65fa46.tar.gz |
Add amqp_end_connection, which closes the socket and destroys the connection
Diffstat (limited to 'librabbitmq')
-rw-r--r-- | librabbitmq/amqp.h | 1 | ||||
-rw-r--r-- | librabbitmq/amqp_connection.c | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h index 139de5d..b67d6c8 100644 --- a/librabbitmq/amqp.h +++ b/librabbitmq/amqp.h @@ -310,6 +310,7 @@ extern int amqp_tune_connection(amqp_connection_state_t state, int heartbeat); int amqp_get_channel_max(amqp_connection_state_t state); extern void amqp_destroy_connection(amqp_connection_state_t state); +extern int amqp_end_connection(amqp_connection_state_t state); extern int amqp_handle_input(amqp_connection_state_t state, amqp_bytes_t received_data, diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c index 8623eed..7531fac 100644 --- a/librabbitmq/amqp_connection.c +++ b/librabbitmq/amqp_connection.c @@ -170,6 +170,15 @@ void amqp_destroy_connection(amqp_connection_state_t state) { free(state); } +int amqp_end_connection(amqp_connection_state_t state) { + int s = state->sockfd; + amqp_destroy_connection(state); + if (close(s) < 0) + return -errno; + else + return 0; +} + static void return_to_idle(amqp_connection_state_t state) { state->inbound_buffer.bytes = NULL; state->inbound_offset = 0; |