[ofw] [PATCH 11/11] librdmacm: windows specific changes

Hefty, Sean sean.hefty at intel.com
Mon Aug 16 16:25:13 PDT 2010


A few changes to the addrinfo support resulting from
differences in the windows implementation of sockets and getaddrinfo.

From: Sean Hefty <sean.hefty at intel.com>
---
 trunk/ulp/librdmacm/src/addrinfo.cpp |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/trunk/ulp/librdmacm/src/addrinfo.cpp b/trunk/ulp/librdmacm/src/addrinfo.cpp
index b9642fe..5d53ca6 100644
--- a/trunk/ulp/librdmacm/src/addrinfo.cpp
+++ b/trunk/ulp/librdmacm/src/addrinfo.cpp
@@ -41,6 +41,34 @@
 #include <rdma/rdma_cma.h>
 #include <rdma/rdma_verbs.h>
 
+static DWORD addr_ref;
+
+static void ucma_startup(void)
+{
+	WSADATA wsadata;
+
+	EnterCriticalSection(&lock);
+	if (addr_ref++) {
+		goto out;
+	}
+
+	if (WSAStartup(MAKEWORD(2, 2), &wsadata)) {
+		addr_ref--;
+	}
+
+out:
+	LeaveCriticalSection(&lock);
+}
+
+static void ucma_shutdown(void)
+{
+	EnterCriticalSection(&lock);
+	if (--addr_ref == 0) {
+		WSACleanup();
+	}
+	LeaveCriticalSection(&lock);
+}
+
 static void ucma_convert_to_ai(struct addrinfo *ai, struct rdma_addrinfo *rai)
 {
 	memset(ai, 0, sizeof *ai);
@@ -136,12 +164,13 @@ int rdma_getaddrinfo(char *node, char *service,
 	struct addrinfo *ai;
 	int ret;
 
+	ucma_startup();
 	if (hints)
 		ucma_convert_to_ai(&ai_hints, hints);
 
 	ret = getaddrinfo(node, service, &ai_hints, &ai);
 	if (ret)
-		return ret;
+		return rdmaw_wsa_errno(ret);
 
 	rai = (struct rdma_addrinfo *) malloc(sizeof(*rai));
 	if (!rai) {
@@ -149,6 +178,8 @@ int rdma_getaddrinfo(char *node, char *service,
 		goto err1;
 	}
 
+	// Windows does not set AI_PASSIVE on output
+	ai->ai_flags |= hints ? hints->ai_flags : 0;
 	ret = ucma_convert_to_rai(rai, ai);
 	if (ret)
 		goto err2;
@@ -208,4 +239,5 @@ void rdma_freeaddrinfo(struct rdma_addrinfo *res)
 
 		free(rai);
 	}
+	ucma_shutdown();
 }




More information about the ofw mailing list