summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Dritschler <timo.dritschler@kit.edu>2014-12-03 19:18:16 +0100
committerTimo Dritschler <timo.dritschler@kit.edu>2014-12-03 19:18:16 +0100
commit9f0b6da7cf20f085d2729e5433f85ffa60a6fd94 (patch)
tree32dcaa3ca28998bea4b8826675d6eb5c91cd5460
parent1817af10022250951ccda1bd31582624fc17ae29 (diff)
downloadkiro-9f0b6da7cf20f085d2729e5433f85ffa60a6fd94.tar.gz
kiro-9f0b6da7cf20f085d2729e5433f85ffa60a6fd94.tar.bz2
kiro-9f0b6da7cf20f085d2729e5433f85ffa60a6fd94.tar.xz
kiro-9f0b6da7cf20f085d2729e5433f85ffa60a6fd94.zip
Fixed two memory leaks in kiro-server
-rw-r--r--src/kiro-server.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/kiro-server.c b/src/kiro-server.c
index 6e4b88a..bedba95 100644
--- a/src/kiro-server.c
+++ b/src/kiro-server.c
@@ -272,7 +272,15 @@ process_cm_event (GIOChannel *source, GIOCondition condition, gpointer data)
else
g_debug ("Got disconnect request from unknown client");
+ // Note:
+ // The ProtectionDomain needs to be buffered and freed manually.
+ // Each connecting client is attached with its own pd, which we
+ // create manually. So we also need to clean it up manually.
+ // This needs to be done AFTER the connection is brought down, so we
+ // buffer the pointer to the pd and clean it up afterwards.
+ struct ibv_pd *pd = ev->id->pd;
kiro_destroy_connection (& (ev->id));
+ g_free (pd);
g_debug ("Connection closed successfully. %u connected clients remaining", g_list_length (priv->clients));
}
@@ -333,8 +341,10 @@ kiro_server_start (KiroServer *self, const char *address, const char *port, void
if (rdma_create_ep (& (priv->base), res_addrinfo, NULL, &qp_attr)) {
g_critical ("Endpoint creation failed: %s", strerror (errno));
+ g_free (res_addrinfo);
return -1;
}
+ g_free (res_addrinfo); // No longer needed
g_debug ("Endpoint created");
char *addr_local = NULL;
@@ -395,7 +405,15 @@ disconnect_client (gpointer data, gpointer user_data)
struct rdma_cm_id *id = (struct rdma_cm_id *)data;
struct kiro_connection_context *ctx = (struct kiro_connection_context *) (id->context);
g_debug ("Disconnecting client: %u", ctx->identifier);
- rdma_disconnect ((struct rdma_cm_id *) data);
+ // Note:
+ // The ProtectionDomain needs to be buffered and freed manually.
+ // Each connecting client is attached with its own pd, which we
+ // create manually. So we also need to clean it up manually.
+ // This needs to be done AFTER the connection is brought down, so we
+ // buffer the pointer to the pd and clean it up afterwards.
+ struct ibv_pd *pd = id->pd;
+ kiro_destroy_connection (&id);
+ g_free (pd);
}
}