aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mds-server.c40
-rw-r--r--src/mds-server.h7
2 files changed, 45 insertions, 2 deletions
diff --git a/src/mds-server.c b/src/mds-server.c
index 8ac2d03..9512457 100644
--- a/src/mds-server.c
+++ b/src/mds-server.c
@@ -20,6 +20,7 @@
#include <libmdsserver/linked-list.h>
#include <libmdsserver/fd-table.h>
+#include <libmdsserver/mds-message.h>
#include <stdio.h>
#include <string.h>
@@ -298,6 +299,8 @@ void* slave_loop(void* data)
ssize_t entry = LINKED_LIST_UNUSED;
client_t* information;
size_t tmp;
+ int r;
+
/* Create information table. */
information = malloc(sizeof(client_t));
@@ -329,14 +332,47 @@ void* slave_loop(void* data)
/* Fill information table. */
information->list_entry = entry;
information->socket_fd = socket_fd;
+ if (mds_message_initialise(&(information->message)))
+ {
+ perror(*argv);
+ goto fail;
+ }
+
+
+ /* Fetch messages from the slave. */
+ for (;;)
+ {
+ r = mds_message_read(&(information->message), socket_fd);
+ if (r == 0)
+ {
+ /* TODO */
+ }
+ else
+ if (r == -2)
+ {
+ fprintf(stderr, "%s: corrupt message received.\n", *argv);
+ goto fail;
+ }
+ else if (errno != EINTR)
+ {
+ perror(*argv);
+ goto fail;
+ }
+ else
+ {
+ /* TODO */
+ }
+ }
- /* TODO */
fail:
/* Close socket and free resources. */
close(socket_fd);
if (information != NULL)
- free(information);
+ {
+ mds_message_destroy(&(information->message));
+ free(information);
+ }
fd_table_remove(&client_map, socket_fd);
/* Unlist client and decrease the slave count. */
diff --git a/src/mds-server.h b/src/mds-server.h
index 5b2ab30..5c41c82 100644
--- a/src/mds-server.h
+++ b/src/mds-server.h
@@ -19,6 +19,8 @@
#define MDS_MDS_SERVER_H
+#include <libmdsserver/mds-message.h>
+
#include <stdlib.h>
@@ -37,6 +39,11 @@ typedef struct client
*/
int socket_fd;
+ /**
+ * Message read buffer for the client
+ */
+ mds_message_t message;
+
} client_t;