]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
acm: Use -1 to indicate an invalid socket rather than 0
authorSean Hefty <sean.hefty@intel.com>
Fri, 25 May 2012 19:23:10 +0000 (12:23 -0700)
committerSean Hefty <sean.hefty@intel.com>
Mon, 28 May 2012 08:11:08 +0000 (01:11 -0700)
socket() can return 0 as a valid socket.  This can happen
when using a daemon that closes stdin/out/err.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/acm.c

index bcf11dadbb1f81533b3324452880caf0259a4f66..9c6591958bcd1b3eda9b8e092e58cdb9a1d325ba 100755 (executable)
--- a/src/acm.c
+++ b/src/acm.c
@@ -61,7 +61,7 @@ typedef struct acm_msg cma_acm_msg_t;
 #endif
 
 static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER;
-static int sock;
+static int sock = -1;
 static short server_port = 6125;
 
 struct ib_connect_hdr {
@@ -108,12 +108,12 @@ void ucma_ib_init(void)
 
 err:
        close(sock);
-       sock = 0;
+       sock = -1;
 }
 
 void ucma_ib_cleanup(void)
 {
-       if (sock > 0) {
+       if (sock >= 0) {
                shutdown(sock, SHUT_RDWR);
                close(sock);
        }
@@ -322,7 +322,7 @@ void ucma_ib_resolve(struct rdma_addrinfo **rai, struct rdma_addrinfo *hints)
        struct acm_ep_addr_data *data;
        int ret;
 
-       if (sock <= 0)
+       if (sock < 0)
                return;
 
        memset(&msg, 0, sizeof msg);