alanxz / rabbitmq-c

RabbitMQ C client
MIT License
1.76k stars 669 forks source link

amqp_exchange_delete() socket hang with non-existent exchange #442

Open MikesAracade opened 7 years ago

MikesAracade commented 7 years ago

Whenever i attempt to delete an non-existing exchange rabbitmq-c hangs for me. I've attached sample code to reproduce the issue. I suspect is has something do with the 404 returned from the passive amqp_exchange_declare() call made right before the delete. I'm a newbie. Be gentle...

rabbitmq_hang_tester.txt

Hang call stack is below:

amqp_poll(int fd=124, int event=2, amqp_timet deadline={...}) Line 259 + 0x26 bytes recv_with_timeout(amqp_connection_statet state=0x006268f0, amqp_timet timeout={...}) Line 725 + 0x13 bytes wait_frame_inner(amqp_connection_statet state=0x006268f0, amqp_framet decoded_frame=0x0017f650, amqp_timet timeout_deadline={...}) Line 839 + 0x11 bytes C simple_rpc_inner(amqp_connection_statet state=0x006268f0, unsigned short channel=1, unsigned int request_id=2621460, unsigned int expected_reply_ids=0x0017f6e8, void decoded_request_method=0x0017f728, amqp_timet deadline={...}) Line 1086 + 0x15 bytes amqp_simple_rpc_decoded(amqp_connection_statet state=0x006268f0, unsigned short channel=1, unsigned int request_id=2621460, unsigned int reply_id=2621461, void decoded_request_method=0x0017f728) Line 1187 + 0x26 bytes amqp_exchange_delete(amqp_connection_statet * state=0x006268f0, unsigned short channel=1, amqp_bytest exchange={...}, int if_unused=0) Line 2052 + 0x1c bytes C main() Line 36 + 0x34 bytes

alanxz commented 7 years ago

After receiving a channel.close from the broker that channel is considered closed and cannot be used. You need to create a new channel to work with before continue, so you should call amqp_channel_open on a new channel before attempting to do anything else.