[rabbitmq-discuss] Why is the "select" always getting timed out in consumer?

kingsmasher1 raj.kumar.sanpui at gmail.com
Fri Dec 13 14:21:11 GMT 2013


This is my latest code which DOES NOT WORK !!!


int amqConnection::isQueueReadable()
{
  int sock = amqp_get_sockfd(conn);
  printf("socket: %d\n", sock);
  int flags = fcntl(sock, F_GETFL, 0);
  fcntl(sock, F_SETFL, flags | O_NONBLOCK);
  if (!amqp_frames_enqueued(conn) && !amqp_data_in_buffer(conn)) {
                         int ret = 0;
                                struct timeval timeout;
                                fd_set read_flags;
                                /* Wait upto a second. */

                        do {
                                FD_ZERO(&read_flags);
                                FD_SET(amqp_get_sockfd(conn), &read_flags);
                                timeout.tv_sec = 5;
                                timeout.tv_usec = 0;
                                ret = select(sock+1, &read_flags, NULL,
NULL, &timeout);
                                if (ret == -1)
                                {
                                        printf("select: error: %d\n",
errno);
                                        return -1;
                                }
                                else if (ret == 0)
                                {
                                        printf("select timedout\n");
                                }


                                if (FD_ISSET(sock, &read_flags)) {
                                        printf("Flag is set\n");
                                        return 1;
                                }
                        } while (ret == 0);
  }
  printf("Buffers started filling\n");
  return -1;
}




--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/Why-is-the-select-always-getting-timed-out-in-consumer-tp32046p32064.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list