From b39079922bb4288dee30dfcb89a0fa0d20e81632 Mon Sep 17 00:00:00 2001 From: Timo Dritschler Date: Fri, 9 May 2014 18:20:11 +0200 Subject: Restructured kiro-server implementation to make it a bit more modular Added interface to kiro-client to access the memory allocated for communication Added new 'kiro_destroy_connection' to kiro-rdma package Changed interface of 'kiro_destroy_connection_context' and updated server and client accordingly Started to implement a more visual testing routine in test-server Made test-client use commandline arguments for address and port Updated Makefile --- kiro-rdma.h | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'kiro-rdma.h') diff --git a/kiro-rdma.h b/kiro-rdma.h index 25040c8..696c880 100644 --- a/kiro-rdma.h +++ b/kiro-rdma.h @@ -156,20 +156,52 @@ static void kiro_destroy_rdma_memory (struct kiro_rdma_mem *krm) } -static void kiro_destroy_connection_context (struct kiro_connection_context *ctx) +static void kiro_destroy_connection_context (struct kiro_connection_context **ctx) { if(!ctx) return; + + if(!(*ctx)) + return; + + if((*ctx)->cf_mr_recv) + kiro_destroy_rdma_memory((*ctx)->cf_mr_recv); + if((*ctx)->cf_mr_send) + kiro_destroy_rdma_memory((*ctx)->cf_mr_send); + + //The RDMA-Memory Region normally contains allocated memory from the USER that has + //just been 'registered' for RDMA. DON'T free it! Just deregister it. The user is + //responsible for freeing this memory. + if((*ctx)->rdma_mr) + { + if((*ctx)->rdma_mr->mr) + ibv_dereg_mr((*ctx)->rdma_mr->mr); + + free((*ctx)->rdma_mr); + (*ctx)->rdma_mr = NULL; + } + + free(*ctx); + *ctx = NULL; +} + + +static void kiro_destroy_connection (struct kiro_connection **conn) +{ + if(!(*conn)) + return; + + if(!(*conn)->id) + return; - if(ctx->cf_mr_recv) - kiro_destroy_rdma_memory(ctx->cf_mr_recv); - if(ctx->cf_mr_send) - kiro_destroy_rdma_memory(ctx->cf_mr_send); - if(ctx->rdma_mr) - kiro_destroy_rdma_memory(ctx->rdma_mr); + rdma_disconnect((*conn)->id); + struct kiro_connection_context *ctx = (struct kiro_connection_context *)((*conn)->id->context); + if(ctx) + kiro_destroy_connection_context(&ctx); - free(ctx); - ctx = NULL; + rdma_destroy_ep((*conn)->id); + free(*conn); + *conn = NULL; } -- cgit v1.2.3