summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimo Dritschler <timo.dritschler@kit.edu>2014-08-28 18:18:18 +0200
committerTimo Dritschler <timo.dritschler@kit.edu>2014-08-28 18:18:18 +0200
commitc126f452df5d29acd0eee8e6ef9f7aaa4b0358a5 (patch)
treeb6cef5a164d0a238b677e08e197ab339c95d0d8b /src
parent0eb7de91194436c5716f5fb2574843628152cc13 (diff)
downloadkiro-c126f452df5d29acd0eee8e6ef9f7aaa4b0358a5.tar.gz
kiro-c126f452df5d29acd0eee8e6ef9f7aaa4b0358a5.tar.bz2
kiro-c126f452df5d29acd0eee8e6ef9f7aaa4b0358a5.tar.xz
kiro-c126f452df5d29acd0eee8e6ef9f7aaa4b0358a5.zip
KIRO Server now sends a disconnect request to all clients upon shutdown
Diffstat (limited to 'src')
-rw-r--r--src/kiro-server.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/kiro-server.c b/src/kiro-server.c
index 171decc..c1d099e 100644
--- a/src/kiro-server.c
+++ b/src/kiro-server.c
@@ -233,8 +233,6 @@ void * event_loop (void *self)
// Post a welcoming "Recieve" for handshaking
if (0 == welcome_client(ev->id, priv->mem, priv->mem_size)) {
// Connection set-up successfully! (Server)
- //new_client->id = ev->id;
- //new_client->identifier = priv->next_client_id;
struct kiro_connection_context *ctx = (struct kiro_connection_context *)(ev->id->context);
ctx->identifier = priv->next_client_id++;
priv->clients = g_list_append (priv->clients, (gpointer)ev->id);
@@ -358,6 +356,18 @@ int kiro_server_start (KiroServer *self, char *address, char *port, void* mem, s
void
+disconnect_client (gpointer data, gpointer user_data)
+{
+ if (data) {
+ struct rdma_cm_id *id = (struct rdma_cm_id *)data;
+ struct kiro_connection_context *ctx = (struct kiro_connection_context *)(id->context);
+ printf ("Disconnecting client: %u.\n", ctx->identifier);
+ rdma_disconnect ((struct rdma_cm_id *) data);
+ }
+}
+
+
+void
kiro_server_stop (KiroServer *self)
{
if(!self)
@@ -375,9 +385,8 @@ kiro_server_stop (KiroServer *self)
printf("Event Listener Thread stopped.\n");
priv->close_signal = 0;
- /*
- * FOR ALL PRIV->CLIENT : DISCONNECT
- */
+ g_list_foreach (priv->clients, disconnect_client, NULL);
+ g_list_free (priv->clients);
rdma_destroy_ep(priv->base);
priv->base = NULL;