diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-07-28 16:21:08 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-07-28 16:21:08 +0200 |
commit | 5f2115bb099cc27c277c4a627d7e56a5b8a41c62 (patch) | |
tree | b85883fdda1b197ccabef5ddf46d5ff47a4baccb /src | |
parent | m + marshal and unmarshal registry table (diff) | |
download | mds-5f2115bb099cc27c277c4a627d7e56a5b8a41c62.tar.gz mds-5f2115bb099cc27c277c4a627d7e56a5b8a41c62.tar.bz2 mds-5f2115bb099cc27c277c4a627d7e56a5b8a41c62.tar.xz |
prepare for handling client closed messages
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mds-registry.c | 37 |
1 files changed, 34 insertions, 3 deletions
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; @@ -467,6 +467,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 * * @param str The client ID string |