From 274ded32a7efd1b422275f02a37273eb65f35dbf Mon Sep 17 00:00:00 2001 From: Vitali Date: Fri, 15 Mar 2013 15:23:40 +0000 Subject: [PATCH] Recover merged but missing commit that makes client send a heartbeat back whenever it receives one. The commit in question: https://github.com/omniti-labs/Net--RabbitMQ/pull/16 --- RabbitMQ.xs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/RabbitMQ.xs b/RabbitMQ.xs index 554030c..d8df3df 100644 --- a/RabbitMQ.xs +++ b/RabbitMQ.xs @@ -101,6 +101,14 @@ int internal_recv(HV *RETVAL, amqp_connection_state_t conn, int piggyback) { amqp_maybe_release_buffers(conn); result = amqp_simple_wait_frame(conn, &frame); if (result <= 0) break; + if (frame.frame_type == AMQP_FRAME_HEARTBEAT) { + // Well, let's send the heartbeat frame back, shouldn't we? + amqp_frame_t hb_resp; + hb_resp.frame_type = AMQP_FRAME_HEARTBEAT; + hb_resp.channel = 0; + amqp_send_frame(conn, &hb_resp); + continue; + } if (frame.frame_type != AMQP_FRAME_METHOD) continue; if (frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD) continue; d = (amqp_basic_deliver_t *) frame.payload.method.decoded; @@ -112,7 +120,13 @@ int internal_recv(HV *RETVAL, amqp_connection_state_t conn, int piggyback) { } result = amqp_simple_wait_frame(conn, &frame); - if (frame.frame_type == AMQP_FRAME_HEARTBEAT) continue; + if (frame.frame_type == AMQP_FRAME_HEARTBEAT) { + amqp_frame_t hb_resp; + hb_resp.frame_type = AMQP_FRAME_HEARTBEAT; + hb_resp.channel = 0; + amqp_send_frame(conn, &hb_resp); + continue; + } if (result <= 0) break; if (frame.frame_type != AMQP_FRAME_HEADER)