From 5f56397b3c3864afad1fd6a86eb773c6b131ddc3 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 12 Aug 2014 14:58:58 +0200 Subject: make it possible to consume messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- doc/messages | 6 +++++- src/mds-server/sending.c | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/messages b/doc/messages index 11409c4..b9bd825 100644 --- a/doc/messages +++ b/doc/messages @@ -95,7 +95,11 @@ is not modified. If the message should be modify it the value of the ‘Modify’ header should be ‘yes’ and the payload should be the new message with all the, possibly modified, headers the new -payload. +payload. A server may also choose to consume a +message message, this is done by responding +without a payload and include ‘Modify: yes’. +Once a message is consumed it will not be sent +to any additional servers. Unless a client's ID is 0:0 (allowed even if it is diff --git a/src/mds-server/sending.c b/src/mds-server/sending.c index 98bb26f..3b78e54 100644 --- a/src/mds-server/sending.c +++ b/src/mds-server/sending.c @@ -127,8 +127,10 @@ static void wait_for_reply(client_t* recipient, uint64_t modify_id) */ void multicast_message(multicast_t* multicast) { + int consumed = 0; uint64_t modify_id = 0; size_t n = strlen("Modify ID: "); + if (startswith_n(multicast->message, "Modify ID: ", multicast->message_length, n)) { char* value = multicast->message + n; @@ -180,9 +182,10 @@ void multicast_message(multicast_t* multicast) if (strequals(mod->headers[i], "Modify: yes")) { modifying = 1; + consumed = mod->payload_size == 0; break; } - if (modifying) + if (modifying && !consumed) { n = mod->payload_size; old_buf = multicast->message; @@ -200,6 +203,9 @@ void multicast_message(multicast_t* multicast) /* Reset how much of the message has been sent before we continue with next recipient. */ multicast->message_ptr = 0; + + if (consumed) + break; } } -- cgit v1.2.3-70-g09d2