From 5f2115bb099cc27c277c4a627d7e56a5b8a41c62 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 28 Jul 2014 16:21:08 +0200 Subject: prepare for handling client closed messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-registry.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mds-registry.c b/src/mds-registry.c index a438c1b..ec1e186 100644 --- a/src/mds-registry.c +++ b/src/mds-registry.c @@ -139,7 +139,7 @@ int initialise_server(void) "Length: 32\n" "\n" "Command: register\n" - "Client closed\n" /* FIXME support not implemented yet */ + "Client closed\n" /* -- NEXT MESSAGE -- */ "Command: reregister\n" "Message ID: 1\n" @@ -391,12 +391,12 @@ int master_loop(void) /** - * Handle the received message + * Handle the received message containing ‘Command: register’-header–value * * @return Zero on success -1 on error or interruption, * errno will be set accordingly */ -int handle_message(void) +static int handle_register_message(void) { const char* recv_client_id = NULL; const char* recv_message_id = NULL; @@ -466,6 +466,37 @@ int handle_message(void) } +/** + * Handle the received message containing a ‘Client closed’-header + * + * @return Zero on success -1 on error or interruption, + * errno will be set accordingly + */ +static int handle_close_message(void) +{ + /* FIXME */ + return 0; +} + + +/** + * Handle the received message + * + * @return Zero on success -1 on error or interruption, + * errno will be set accordingly + */ +int handle_message(void) +{ + size_t i; + for (i = 0; i < received.header_count; i++) + { + if (strequals(received.headers[i], "Command: register")) + return handle_register_message(); + } + return handle_close_message(); +} + + /** * Convert a client ID string into a client ID integer * -- cgit v1.2.3-70-g09d2