Function amqp_destroy_connection

Synopsis

#include <librabbitmq/amqp.h>

int amqp_destroy_connection(amqp_connection_state_t state)

Description

Destroys an amqp_connection_state_t object

Destroys a amqp_connection_state_t object that was created with amqp_new_connection(). If the connection with the broker is open, it will be implicitly closed with a reply code of 200 (success). Any memory that would be freed with amqp_maybe_release_buffers() or amqp_maybe_release_buffers_on_channel() will be freed, and use of that memory will caused undefined behavior.

Parameters:

[ in ] state - the connection object

Return
AMQP_STATUS_OK on success. amqp_status_enum value failure
See
amqp_new_connection()
Since
v0.1

Mentioned in

Source

Lines 189-210 in librabbitmq/amqp_connection.c. Line 1178 in librabbitmq/amqp.h.

int amqp_destroy_connection(amqp_connection_state_t state) {
  int status = AMQP_STATUS_OK;
  if (state) {
    int i;
    for (i = 0; i < POOL_TABLE_SIZE; ++i) {
      amqp_pool_table_entry_t *entry = state->pool_table[i];
      while (NULL != entry) {
        amqp_pool_table_entry_t *todelete = entry;
        empty_amqp_pool(&entry->pool);
        entry = entry->next;
        free(todelete);
      }
    }

    free(state->outbound_buffer.bytes);
    free(state->sock_inbound_buffer.bytes);
    amqp_socket_delete(state->socket);
    empty_amqp_pool(&state->properties_pool);
    free(state);
  }
  return status;
}





Add Discussion as Guest

Log in to DocsForge