[rabbitmq-discuss] socket read timeout in rabbitmq-c

Scott Brooks scott at beamdog.com
Thu May 6 01:33:36 BST 2010


This may not solve your exact problem but it may help

You can pull the socket out of rabbitmq-c with
amqp_get_sockfd
and then you can query
amqp_data_in_buffer

If amqp_data_in_buffer returns true, then the next read will return a
packet from inside it's internal buffer, and not check the network
If it returns false, select on the sockfd from amqp_get_sockfd to see
if there is data to be retrieved.

Only then call a possibly blocking function.

Scott


On Wed, May 5, 2010 at 5:35 PM, alex chen <chen650 at yahoo.com> wrote:
>
> Hi,
>
> We are using rabbitmq-c.  It seems to me most of the functions such as amqp_login and amqp_channel_open call amqp_simple_rpc, which sends the request and waits for response.  There seems to be no way to specify timeout value for waiting the response.  the amqp_socket.c::wait_frame_inner() calls read() and it may block forever if the response is net received.
>
> I am wondering if it can support specifying a time out (e.g. amqp_set_timeout(int timeout)), and add select(timeout) before the read() in wait_frame?  We found in several cases that amqp_channel_open hanged while doing read() in wait_frame_inner().  here is the stack trace:
>
> (gdb) where
> #0  0xffffe410 in __kernel_vsyscall ()
> #1  0xf7fbc69b in __read_nocancel () from /lib/tls/libpthread.so.0
> #2  0xf7fdf3e3 in wait_frame_inner (state=0x8053938, decoded_frame=0xf7732180) at amqp_socket.c:147
> #3  0xf7fdf64f in amqp_simple_rpc (state=0x8053938, channel=1, request_id=1310730, expected_reply_ids=0xf77321f8,
> decoded_request_method=0xf77321f0) at amqp_socket.c:251
> #4  0xf7fdff3b in amqp_channel_open (state=0x8053938, channel=1) at
> amqp_api.c:22
>
> thanks.
>
> -alex
>
>
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss



More information about the rabbitmq-discuss mailing list