Function amqp_try_recv

Synopsis

#include <librabbitmq/amqp_private.h>

int amqp_try_recv(amqp_connection_state_t state)

Description

No description yet.

Source

Lines 722-769 in librabbitmq/amqp_socket.c. Line 211 in librabbitmq/amqp_private.h.

int amqp_try_recv(amqp_connection_state_t state) {
  amqp_time_t timeout;

  while (amqp_data_in_buffer(state)) {
    amqp_frame_t frame;
    int res = consume_one_frame(state, &frame);

    if (AMQP_STATUS_OK != res) {
      return res;
    }

    if (frame.frame_type != 0) {
      amqp_pool_t *channel_pool;
      amqp_frame_t *frame_copy;
      amqp_link_t *link;

      channel_pool = amqp_get_or_create_channel_pool(state, frame.channel);
      if (NULL == channel_pool) {
        return AMQP_STATUS_NO_MEMORY;
      }

      frame_copy = amqp_pool_alloc(channel_pool, sizeof(amqp_frame_t));
      link = amqp_pool_alloc(channel_pool, sizeof(amqp_link_t));

      if (frame_copy == NULL || link == NULL) {
        return AMQP_STATUS_NO_MEMORY;
      }

      *frame_copy = frame;

      link->next = NULL;
      link->data = frame_copy;

      if (state->last_queued_frame == NULL) {
        state->first_queued_frame = link;
      } else {
        state->last_queued_frame->next = link;
      }
      state->last_queued_frame = link;
    }
  }
  int res = amqp_time_s_from_now(&timeout, 0);
  if (AMQP_STATUS_OK != res) {
    return res;
  }

  return recv_with_timeout(state, timeout);
}





Add Discussion as Guest

Log in to DocsForge