summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Willi <martin.willi@cloudguard.ch>2017-03-23 09:48:06 +0100
committerMartin Willi <martin.willi@cloudguard.ch>2017-03-23 10:01:39 +0100
commit4a8744fc5874a6d09a72d87d11326f64317004f2 (patch)
tree53a94d325c9e607cb9efd11999096a2874e288f0
parentbaabb2addee3047517e25b4723c48db852255d6e (diff)
downloadrabbitmq-c-4a8744fc5874a6d09a72d87d11326f64317004f2.tar.gz
Lib: Do not set MSG_MORE on last message header if no body follows
Introduced with commit 2bc1f9b1b0 (lib: use MSG_MORE on Linux for basic.publish), amqp_basic_publish() sets MSG_MORE on all but the last send() syscall it triggers on the TCP socket to improve performance. However, if no message body is provided, no completing call without MSG_MORE follows, keeping the TCP packet pending. On Linux, this may introduce a message send delay, until the kernel sends out the data anyway after 200ms. This may add a significant delay if a consumer is waiting for such an empty (confirmation) message.
-rw-r--r--librabbitmq/amqp_api.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/librabbitmq/amqp_api.c b/librabbitmq/amqp_api.c
index cafc2f7..8c47cd0 100644
--- a/librabbitmq/amqp_api.c
+++ b/librabbitmq/amqp_api.c
@@ -183,6 +183,7 @@ int amqp_basic_publish(amqp_connection_state_t state,
size_t body_offset;
size_t usable_body_payload_size = state->frame_max - (HEADER_SIZE + FOOTER_SIZE);
int res;
+ int flagz;
amqp_basic_publish_t m;
amqp_basic_properties_t default_properties;
@@ -224,7 +225,12 @@ int amqp_basic_publish(amqp_connection_state_t state,
f.payload.properties.body_size = body.len;
f.payload.properties.decoded = (void *) properties;
- res = amqp_send_frame_inner(state, &f, AMQP_SF_MORE, amqp_time_infinite());
+ if (body.len > 0) {
+ flagz = AMQP_SF_MORE;
+ } else {
+ flagz = AMQP_SF_NONE;
+ }
+ res = amqp_send_frame_inner(state, &f, flagz, amqp_time_infinite());
if (res < 0) {
return res;
}
@@ -232,7 +238,6 @@ int amqp_basic_publish(amqp_connection_state_t state,
body_offset = 0;
while (body_offset < body.len) {
size_t remaining = body.len - body_offset;
- int flagz;
if (remaining == 0) {
break;