qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cliffjan...@apache.org
Subject qpid-proton git commit: PROTON-1601: make Windows more like Posix in handling the unpecified address for outbound connections
Date Thu, 05 Oct 2017 22:50:31 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master b22b7c233 -> 446ade386


PROTON-1601: make Windows more like Posix in handling the unpecified address for outbound
connections


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/446ade38
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/446ade38
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/446ade38

Branch: refs/heads/master
Commit: 446ade386dab7e0cf163f435beee467e0e294c93
Parents: b22b7c2
Author: Clifford Jansen <cliffjansen@apache.org>
Authored: Thu Oct 5 15:50:41 2017 -0700
Committer: Clifford Jansen <cliffjansen@apache.org>
Committed: Thu Oct 5 15:50:41 2017 -0700

----------------------------------------------------------------------
 proton-c/src/proactor/win_iocp.c | 14 +++++++++++++-
 proton-c/src/tests/proactor.c    |  2 --
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/446ade38/proton-c/src/proactor/win_iocp.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/win_iocp.c b/proton-c/src/proactor/win_iocp.c
index 9a27ae6..0b78075 100644
--- a/proton-c/src/proactor/win_iocp.c
+++ b/proton-c/src/proactor/win_iocp.c
@@ -2727,7 +2727,19 @@ void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, const
char *addr)
   proactor_add(&pc->context);
   pn_connection_open(pc->driver.connection); /* Auto-open */
 
-  if (!pgetaddrinfo(pc->psocket.host, pc->psocket.port, 0, &pc->addrinfo)) {
+  const char *host = pc->psocket.host;
+  if (host) {
+    static const char *ipv4loopback = "127.0.0.1";
+    static const char *ipv6loopback = "::1";
+    // Convert "0.0.0.0" or "::" to loopback on Windows for outgoing sockets.
+    // This approximates posix behavior for the unspecified address.
+    if (!strcmp("0.0.0.0", host))
+      host = ipv4loopback;
+    else if (!strcmp("::", host))
+      host = ipv6loopback;
+  }
+
+  if (!pgetaddrinfo(host, pc->psocket.port, 0, &pc->addrinfo)) {
     pc->ai = pc->addrinfo;
     if (connect_step(pc)) {
       return;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/446ade38/proton-c/src/tests/proactor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/proactor.c b/proton-c/src/tests/proactor.c
index be00f46..c34e0ed 100644
--- a/proton-c/src/tests/proactor.c
+++ b/proton-c/src/tests/proactor.c
@@ -691,9 +691,7 @@ static void test_ipv4_ipv6(test_t *t) {
   EXPECT_CONNECT(l.port, "");          /* local->all */
 
   if (has_ipv6) {
-#if !defined(_WIN32)
     EXPECT_CONNECT(l6.port, "::"); /* v6->v6 */
-#endif
     EXPECT_CONNECT(l6.port, "");     /* local->v6 */
     EXPECT_CONNECT(l.port, "::1"); /* v6->all */
 


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


Mime
View raw message