From 0617f29955a1c7ce712c875d6216de8544ec7249 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 7 May 2014 18:27:17 +0200 Subject: send to clients (does not implement modifiers yet) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-server.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/mds-server.c b/src/mds-server.c index 8f0e8fe..7bd79df 100644 --- a/src/mds-server.c +++ b/src/mds-server.c @@ -1045,7 +1045,35 @@ void multicast_message(char* message, size_t length) /* Sort interceptors. */ qsort(interceptions, interceptions_count, sizeof(queued_interception_t), cmp_queued_interception); - /* TODO */ + /* Send message to interceptors. */ + for (i = 0; i < interceptions_count; i++) + { + queued_interception_t client_ = interceptions[i]; + client_t* client = client_.client; + char* msg = message; + size_t sent; + n = length; + + with_mutex(client->mutex, + while (n > 0) + { + sent = send_message(client->socket_fd, msg, n); + if ((sent < n) && (errno != EINTR)) /* Ignore EINTR */ + { + perror(*argv); + break; + } + n -= sent; + msg += sent; + } + ); + + if ((n > 0) && client_.modifying) + { + /* TODO */ + } + } + errno = 0; fail: /* This is done before this function returns even if there was no error. */ -- cgit v1.2.3-70-g09d2