From 31070fa710b1a06e468cc03c486b9c7fbe39e462 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 13 May 2010 02:26:14 +0000 Subject: Allow rdma_disconnect() to fail with EINVAL as it appears to be necessary to call rdma_disconnect() after receiving a disconnection event in Infiniband, but it's not allowed on iWarp as the disconnect event has already disconnected the queue pair. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@943770 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/rdma/rdma_exception.h | 4 ++++ cpp/src/qpid/sys/rdma/rdma_wrap.h | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'cpp/src/qpid/sys') diff --git a/cpp/src/qpid/sys/rdma/rdma_exception.h b/cpp/src/qpid/sys/rdma/rdma_exception.h index 7867aef2e4..a3a289e38a 100644 --- a/cpp/src/qpid/sys/rdma/rdma_exception.h +++ b/cpp/src/qpid/sys/rdma/rdma_exception.h @@ -48,6 +48,10 @@ namespace Rdma { throw Rdma::Exception((rc == -1) ? errno : rc >0 ? rc : -rc); } + inline int GETERR(int rc) { + return (rc == -1) ? errno : rc > 0 ? rc : -rc; + } + inline void CHECK_IBV(int rc) { if (rc != 0) throw Rdma::Exception(rc); diff --git a/cpp/src/qpid/sys/rdma/rdma_wrap.h b/cpp/src/qpid/sys/rdma/rdma_wrap.h index 35843ce8f1..bea5a5d979 100644 --- a/cpp/src/qpid/sys/rdma/rdma_wrap.h +++ b/cpp/src/qpid/sys/rdma/rdma_wrap.h @@ -344,7 +344,7 @@ namespace Rdma { assert(id.get()); ::rdma_cm_event* e; int rc = ::rdma_get_cm_event(id->channel, &e); - if (rc == -1 && errno == EAGAIN) + if (GETERR(rc) == EAGAIN) return ConnectionEvent(); CHECK(rc); return ConnectionEvent(e); @@ -375,7 +375,13 @@ namespace Rdma { void disconnect() const { assert(id.get()); - CHECK(::rdma_disconnect(id.get())); + int rc = ::rdma_disconnect(id.get()); + // iWarp doesn't let you disconnect a disconnected connection + // but Infiniband can do so it's okay to call rdma_disconnect() + // in response to a disconnect event, but we may get an error + if (GETERR(rc) == EINVAL) + return; + CHECK(rc); } // TODO: Currently you can only connect with the default connection parameters -- cgit v1.2.1