summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_private.h
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2015-04-21 23:41:42 -0700
committerAlan Antonuk <alan.antonuk@gmail.com>2015-05-03 20:24:02 -0700
commit5498dc66c3be4176c3631ee4b4ec26d6cb4966ae (patch)
treee0b16bc62d0c647bef581faae204cdf4dcf790ce /librabbitmq/amqp_private.h
parenta1326beab0054f35cf607297ae47ed3330086585 (diff)
downloadrabbitmq-c-5498dc66c3be4176c3631ee4b4ec26d6cb4966ae.tar.gz
Refactor heartbeat timeout code to be simpler
Refactor the heartbeat timeout code to hopefully simplify it and hopefully make it less hairy to deal with in the future.
Diffstat (limited to 'librabbitmq/amqp_private.h')
-rw-r--r--librabbitmq/amqp_private.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/librabbitmq/amqp_private.h b/librabbitmq/amqp_private.h
index 62c8ff0..9497cc8 100644
--- a/librabbitmq/amqp_private.h
+++ b/librabbitmq/amqp_private.h
@@ -156,7 +156,13 @@ struct amqp_connection_state_t_ {
int channel_max;
int frame_max;
+
+ /* Heartbeat interval in seconds. If this is <= 0, then heartbeats are not
+ * enabled, and next_recv_heartbeat and next_send_heartbeat are set to
+ * infinite */
int heartbeat;
+ amqp_time_t next_recv_heartbeat;
+ amqp_time_t next_send_heartbeat;
/* buffer for holding frame headers. Allows us to delay allocating
* the raw frame buffer until the type, channel, and size are all known
@@ -180,9 +186,6 @@ struct amqp_connection_state_t_ {
amqp_rpc_reply_t most_recent_api_result;
- uint64_t next_recv_heartbeat;
- uint64_t next_send_heartbeat;
-
amqp_table_t server_properties;
amqp_pool_t properties_pool;
};
@@ -190,19 +193,13 @@ struct amqp_connection_state_t_ {
amqp_pool_t *amqp_get_or_create_channel_pool(amqp_connection_state_t connection, amqp_channel_t channel);
amqp_pool_t *amqp_get_channel_pool(amqp_connection_state_t state, amqp_channel_t channel);
-static inline amqp_boolean_t amqp_heartbeat_enabled(amqp_connection_state_t state)
-{
- return (state->heartbeat > 0);
-}
-static inline uint64_t amqp_calc_next_send_heartbeat(amqp_connection_state_t state, uint64_t cur)
-{
- return cur + ((uint64_t)state->heartbeat * AMQP_NS_PER_S);
+static inline int amqp_heartbeat_send(amqp_connection_state_t state) {
+ return state->heartbeat;
}
-static inline uint64_t amqp_calc_next_recv_heartbeat(amqp_connection_state_t state, uint64_t cur)
-{
- return cur + ((uint64_t)state->heartbeat * 2 * AMQP_NS_PER_S);
+static inline int amqp_heartbeat_recv(amqp_connection_state_t state) {
+ return 2 * state->heartbeat;
}
int amqp_try_recv(amqp_connection_state_t state);