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

From: Sean Hefty <[email protected]>
---
 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();
 }

_______________________________________________
ofw mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw

Reply via email to