summaryrefslogtreecommitdiff
path: root/librabbitmq
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonyg@lshift.net>2009-08-20 11:31:54 +0100
committerTony Garnock-Jones <tonyg@lshift.net>2009-08-20 11:31:54 +0100
commit80ffcbabdb628ad4c1cd19c0b9ff398cf63f9a7f (patch)
treef21995fad049be7ef3f842fbc5befd17468ed68f /librabbitmq
parent6f89af777b6704fe7f9521a30449f8369c7492b9 (diff)
parent752c7922ff97d1f373589f2b301cd30aec8e36f6 (diff)
downloadrabbitmq-c-github-ask-80ffcbabdb628ad4c1cd19c0b9ff398cf63f9a7f.tar.gz
Merge default into amqp_0_9_1
Diffstat (limited to 'librabbitmq')
-rw-r--r--librabbitmq/amqp.h4
-rw-r--r--librabbitmq/amqp_connection.c6
-rw-r--r--librabbitmq/amqp_private.h1
-rw-r--r--librabbitmq/amqp_socket.c14
4 files changed, 19 insertions, 6 deletions
diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h
index 6a1cace..efb4b45 100644
--- a/librabbitmq/amqp.h
+++ b/librabbitmq/amqp.h
@@ -142,7 +142,8 @@ extern void amqp_set_sockfd(amqp_connection_state_t state,
int sockfd);
extern int amqp_tune_connection(amqp_connection_state_t state,
int channel_max,
- int frame_max);
+ int frame_max,
+ int heartbeat);
int amqp_get_channel_max(amqp_connection_state_t state);
extern void amqp_destroy_connection(amqp_connection_state_t state);
@@ -206,6 +207,7 @@ extern amqp_rpc_reply_t amqp_login(amqp_connection_state_t state,
char const *vhost,
int channel_max,
int frame_max,
+ int heartbeat,
amqp_sasl_method_enum sasl_method, ...);
extern amqp_rpc_reply_t amqp_rpc_reply;
diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c
index 9653694..d01af66 100644
--- a/librabbitmq/amqp_connection.c
+++ b/librabbitmq/amqp_connection.c
@@ -42,7 +42,7 @@ amqp_connection_state_t amqp_new_connection(void) {
state->inbound_buffer.bytes = NULL;
state->outbound_buffer.bytes = NULL;
- if (amqp_tune_connection(state, 0, INITIAL_FRAME_POOL_PAGE_SIZE) != 0) {
+ if (amqp_tune_connection(state, 0, INITIAL_FRAME_POOL_PAGE_SIZE, 0) != 0) {
empty_amqp_pool(&state->frame_pool);
empty_amqp_pool(&state->decoding_pool);
free(state);
@@ -81,7 +81,8 @@ void amqp_set_sockfd(amqp_connection_state_t state,
int amqp_tune_connection(amqp_connection_state_t state,
int channel_max,
- int frame_max)
+ int frame_max,
+ int heartbeat)
{
void *newbuf;
@@ -89,6 +90,7 @@ int amqp_tune_connection(amqp_connection_state_t state,
state->channel_max = channel_max;
state->frame_max = frame_max;
+ state->heartbeat = heartbeat;
empty_amqp_pool(&state->frame_pool);
init_amqp_pool(&state->frame_pool, frame_max);
diff --git a/librabbitmq/amqp_private.h b/librabbitmq/amqp_private.h
index 0f9987a..98a7a65 100644
--- a/librabbitmq/amqp_private.h
+++ b/librabbitmq/amqp_private.h
@@ -56,6 +56,7 @@ struct amqp_connection_state_t_ {
int channel_max;
int frame_max;
+ int heartbeat;
amqp_bytes_t inbound_buffer;
size_t inbound_offset;
diff --git a/librabbitmq/amqp_socket.c b/librabbitmq/amqp_socket.c
index 7a87281..78cb8ba 100644
--- a/librabbitmq/amqp_socket.c
+++ b/librabbitmq/amqp_socket.c
@@ -284,12 +284,14 @@ amqp_rpc_reply_t amqp_simple_rpc(amqp_connection_state_t state,
static int amqp_login_inner(amqp_connection_state_t state,
int channel_max,
int frame_max,
+ int heartbeat,
amqp_sasl_method_enum sasl_method,
va_list vl)
{
amqp_method_t method;
uint32_t server_frame_max;
uint16_t server_channel_max;
+ uint16_t server_heartbeat;
amqp_send_header(state);
@@ -325,6 +327,7 @@ static int amqp_login_inner(amqp_connection_state_t state,
amqp_connection_tune_t *s = (amqp_connection_tune_t *) method.decoded;
server_channel_max = s->channel_max;
server_frame_max = s->frame_max;
+ server_heartbeat = s->heartbeat;
}
if (server_channel_max != 0 && server_channel_max < channel_max) {
@@ -335,14 +338,18 @@ static int amqp_login_inner(amqp_connection_state_t state,
frame_max = server_frame_max;
}
- AMQP_CHECK_RESULT(amqp_tune_connection(state, channel_max, frame_max));
+ if (server_heartbeat != 0 && server_heartbeat < heartbeat) {
+ heartbeat = server_heartbeat;
+ }
+
+ AMQP_CHECK_RESULT(amqp_tune_connection(state, channel_max, frame_max, heartbeat));
{
amqp_connection_tune_ok_t s =
(amqp_connection_tune_ok_t) {
.channel_max = channel_max,
.frame_max = frame_max,
- .heartbeat = 0
+ .heartbeat = heartbeat
};
AMQP_CHECK_RESULT(amqp_send_method(state, 0, AMQP_CONNECTION_TUNE_OK_METHOD, &s));
}
@@ -356,6 +363,7 @@ amqp_rpc_reply_t amqp_login(amqp_connection_state_t state,
char const *vhost,
int channel_max,
int frame_max,
+ int heartbeat,
amqp_sasl_method_enum sasl_method,
...)
{
@@ -364,7 +372,7 @@ amqp_rpc_reply_t amqp_login(amqp_connection_state_t state,
va_start(vl, sasl_method);
- amqp_login_inner(state, channel_max, frame_max, sasl_method, vl);
+ amqp_login_inner(state, channel_max, frame_max, heartbeat, sasl_method, vl);
{
amqp_connection_open_t s =