Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Issue 196094: Non-blocking connect() attempts may fail synchronously (Closed)

Created:
11 years, 3 months ago by Mark Mentovai
Modified:
9 years, 7 months ago
Reviewers:
wtc
CC:
chromium-reviews_googlegroups.com, darin (slow to review), brettw
Visibility:
Public.

Description

Non-blocking connect() attempts may fail synchronously in some cases. When this occurs, connect() should be retried with another address if possible and appropriate. On Mac OS X 10.6 ("Snow Leopard"), getaddrinfo() returns IPv6 addresses even when inappropriate due to the use of AI_ADDRCONFIG. connect() fails immediately when trying to connect to an IPv6 address from a system that only has IPv4 connectivity. The existing net::TCPClientSocketLibevent is not prepared to deal with immediate connect() failures, so it fails without trying additional addresses. Some sites, such as python.org, publish both IPv4 and IPv6 addresses. On Snow Leopard, name resolution always returns the IPv6 addresses first, rendering such sites impossible to connect to unless reachable by IPv6. This change restores the previous behavior of setting AI_ADDRCONFIG when calling getaddrinfo() on Mac OS X. AI_ADDRCONFIG was removed in a previous attempt to fix this bug. AI_ADDRCONFIG is now documented in Snow Leopard. The associated comment, written for Mac OS X 10.5 ("Leopard"), is no longer correct. In most cases, the presence or absence of this flag seems to have no impact on the system resolver's behavior, but I believe that its presence is correct per the documentation. A separate bug will be filed with Apple. BUG=12711 TEST=http://python.org/ on Snow Leopard should load on a machine where only IPv4 is available; it (and all other sites) should continue to function properly on Leopard Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=26051

Patch Set 1 #

Total comments: 4

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 2

Patch Set 4 : '' #

Patch Set 5 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+49 lines, -40 lines) Patch
M net/base/host_resolver_proc.cc View 1 chunk +0 lines, -17 lines 0 comments Download
M net/socket/tcp_client_socket_libevent.cc View 1 2 3 4 3 chunks +49 lines, -23 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Mark Mentovai
Wan-Teh, I wonder if we also want to add ENETDOWN to the list of errors ...
11 years, 3 months ago (2009-09-11 21:03:58 UTC) #1
wtc
LGTM! Thanks for tracking this down. Note: I found that the use of 'addrinfo', without ...
11 years, 3 months ago (2009-09-11 21:31:55 UTC) #2
Mark Mentovai
New version up.
11 years, 3 months ago (2009-09-11 22:10:22 UTC) #3
wtc
11 years, 3 months ago (2009-09-11 22:32:34 UTC) #4
Looks good!

http://codereview.chromium.org/196094/diff/6001/6002
File net/socket/tcp_client_socket_libevent.cc (right):

http://codereview.chromium.org/196094/diff/6001/6002#newcode91
Line 91: case ENETDOWN:
Nit: list ENETDOWN after EHOSTUNREACH because they are
related.

http://codereview.chromium.org/196094/diff/6001/6002#newcode126
Line 126: bool try_next_address;
It seems that you can write the loop like:
  for (;;) {
    ..
    if (error_code == EINPROGRESS)
      break;
    ...
  }
and get rid of the try_next_address boolean.

Powered by Google App Engine
This is Rietveld 408576698