From 393e2dfd57cedaacf5fb7b533c019143d8d2eba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Ho=CC=88rberg?= Date: Mon, 13 Jul 2015 10:42:01 +0200 Subject: If channel_max is 0, use server's channel_max --- librabbitmq/amqp.h | 8 ++++++-- librabbitmq/amqp_socket.c | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h index f82273c..bfa7d26 100644 --- a/librabbitmq/amqp.h +++ b/librabbitmq/amqp.h @@ -1749,7 +1749,9 @@ AMQP_CALL amqp_get_rpc_reply(amqp_connection_state_t state); * \param [in] channel_max the limit for number of channels for the connection. * 0 means no limit, and is a good default (AMQP_DEFAULT_MAX_CHANNELS) * Note that the maximum number of channels the protocol supports - * is 65535 (2^16, with the 0-channel reserved) + * is 65535 (2^16, with the 0-channel reserved). The server can + * set a lower channel_max and then the client will use the lowest + * of the two * \param [in] frame_max the maximum size of an AMQP frame on the wire to * request of the broker for this connection. 4096 is the minimum * size, 2^31-1 is the maximum, a good default is 131072 (128KB), or @@ -1806,7 +1808,9 @@ AMQP_CALL amqp_login(amqp_connection_state_t state, char const *vhost, * \param [in] channel_max the limit for the number of channels for the connection. * 0 means no limit, and is a good default (AMQP_DEFAULT_MAX_CHANNELS) * Note that the maximum number of channels the protocol supports - * is 65535 (2^16, with the 0-channel reserved) + * is 65535 (2^16, with the 0-channel reserved). The server can + * set a lower channel_max and then the client will use the lowest + * of the two * \param [in] frame_max the maximum size of an AMQP frame ont he wire to * request of the broker for this connection. 4096 is the minimum * size, 2^31-1 is the maximum, a good default is 131072 (128KB), or diff --git a/librabbitmq/amqp_socket.c b/librabbitmq/amqp_socket.c index c110765..b60573f 100644 --- a/librabbitmq/amqp_socket.c +++ b/librabbitmq/amqp_socket.c @@ -1354,7 +1354,8 @@ static amqp_rpc_reply_t amqp_login_inner(amqp_connection_state_t state, server_heartbeat = s->heartbeat; } - if (server_channel_max != 0 && server_channel_max < channel_max) { + if (server_channel_max != 0 && + (server_channel_max < channel_max || channel_max == 0)) { channel_max = server_channel_max; } else if (server_channel_max == 0 && channel_max == 0) { channel_max = UINT16_MAX; -- cgit v1.2.1