qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cliffjan...@apache.org
Subject svn commit: r1626923 - /qpid/proton/trunk/proton-c/src/windows/io.c
Date Tue, 23 Sep 2014 01:11:15 GMT
Author: cliffjansen
Date: Tue Sep 23 01:11:15 2014
New Revision: 1626923

URL: http://svn.apache.org/r1626923
Log:
PROTON-684: Restrict IOCP enlistment to pn_selector_t usage scenarios in Windows

Modified:
    qpid/proton/trunk/proton-c/src/windows/io.c

Modified: qpid/proton/trunk/proton-c/src/windows/io.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/windows/io.c?rev=1626923&r1=1626922&r2=1626923&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/windows/io.c (original)
+++ qpid/proton/trunk/proton-c/src/windows/io.c Tue Sep 23 01:11:15 2014
@@ -210,14 +210,16 @@ pn_socket_t pn_listen(pn_io_t *io, const
     return INVALID_SOCKET;
   }
 
-  iocpdesc_t *iocpd = pni_iocpdesc_create(io->iocp, sock, false);
-  if (!iocpd) {
-    pn_i_error_from_errno(io->error, "register");
-    closesocket(sock);
-    return INVALID_SOCKET;
+  if (io->iocp->selector) {
+    iocpdesc_t *iocpd = pni_iocpdesc_create(io->iocp, sock, false);
+    if (!iocpd) {
+      pn_i_error_from_errno(io->error, "register");
+      closesocket(sock);
+      return INVALID_SOCKET;
+    }
+    pni_iocpdesc_start(iocpd);
   }
 
-  pni_iocpdesc_start(iocpd);
   return sock;
 }
 
@@ -242,7 +244,22 @@ pn_socket_t pn_connect(pn_io_t *io, cons
 
   ensure_unique(io, sock);
   pn_configure_sock(io, sock);
-  return pni_iocp_begin_connect(io->iocp, sock, addr, io->error);
+
+  if (io->iocp->selector) {
+    return pni_iocp_begin_connect(io->iocp, sock, addr, io->error);
+  } else {
+    if (connect(sock, addr->ai_addr, addr->ai_addrlen) != 0) {
+      if (WSAGetLastError() != WSAEWOULDBLOCK) {
+	pni_win32_error(io->error, "connect", WSAGetLastError());
+	freeaddrinfo(addr);
+	closesocket(sock);
+	return INVALID_SOCKET;
+      }
+    }
+
+    freeaddrinfo(addr);
+    return sock;
+  }
 }
 
 pn_socket_t pn_accept(pn_io_t *io, pn_socket_t listen_sock, char *name, size_t size)



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message