diff options
author | Timo Dritschler <timo.dritschler@kit.edu> | 2014-08-29 18:44:23 +0200 |
---|---|---|
committer | Timo Dritschler <timo.dritschler@kit.edu> | 2014-08-29 18:44:23 +0200 |
commit | 268b867c719717f12d5e57e6ca93e6f6cfd04a35 (patch) | |
tree | 25294d729922127c84b78db36a00a0f0bcad915f | |
parent | ecf1e0a95fff6b4bcf23c537824faf4768f8f65f (diff) | |
download | kiro-268b867c719717f12d5e57e6ca93e6f6cfd04a35.tar.gz kiro-268b867c719717f12d5e57e6ca93e6f6cfd04a35.tar.bz2 kiro-268b867c719717f12d5e57e6ca93e6f6cfd04a35.tar.xz kiro-268b867c719717f12d5e57e6ca93e6f6cfd04a35.zip |
Fixed a problem in KIRO Client "sync" function
KIRO Client was ignoring broken connections and bad RDMA access keys
Made test-client application check kiro_client_sync return value
-rw-r--r-- | src/kiro-client.c | 32 | ||||
-rw-r--r-- | test/test-client.c | 5 |
2 files changed, 31 insertions, 6 deletions
diff --git a/src/kiro-client.c b/src/kiro-client.c index c4ef9ed..2f0671b 100644 --- a/src/kiro-client.c +++ b/src/kiro-client.c @@ -208,6 +208,12 @@ int kiro_client_sync (KiroClient *self) { KiroClientPrivate *priv = KIRO_CLIENT_GET_PRIVATE (self); + + if (!priv->conn) { + g_warning ("Client not connected"); + return -1; + } + struct kiro_connection_context *ctx = (struct kiro_connection_context *)priv->conn->context; if (rdma_post_read (priv->conn, priv->conn, ctx->rdma_mr->mem, ctx->peer_mr.length, ctx->rdma_mr->mr, 0, ctx->peer_mr.addr, ctx->peer_mr.rkey)) { @@ -222,13 +228,29 @@ kiro_client_sync (KiroClient *self) if (rdma_get_send_comp (priv->conn, &wc) < 0) { g_critical ("No send completion for RDMA_READ received: %s", strerror (errno)); - rdma_disconnect (priv->conn); - kiro_destroy_connection_context (&ctx); - rdma_destroy_ep (priv->conn); - return -1; + goto fail; } - return 0; + switch (wc.status) { + case IBV_WC_SUCCESS: + return 0; + case IBV_WC_RETRY_EXC_ERR: + g_critical ("Server no longer responding"); + break; + case IBV_WC_REM_ACCESS_ERR: + g_critical ("Server has revoked access right to read data"); + break; + default: + g_critical ("Could not get data from server. Status %u", wc.status); + } + + +fail: + rdma_disconnect (priv->conn); + kiro_destroy_connection_context (&ctx); + rdma_destroy_ep (priv->conn); + priv->conn = NULL; + return -1; } diff --git a/test/test-client.c b/test/test-client.c index 45ce722..a7bbc16 100644 --- a/test/test-client.c +++ b/test/test-client.c @@ -80,7 +80,10 @@ main ( int argc, char *argv[] ) for (SDL_Event event; SDL_PollEvent (&event);) if (event.type == SDL_QUIT) cont = 0; - kiro_client_sync (client); + if (kiro_client_sync (client) < 0) { + g_warning ("Unable to get data from server. Stopping."); + break; + } SDL_Delay (10); render (data_sf); } |