Skip to content

Commit

Permalink
Use the correct addrinfo entry in the connect loop
Browse files Browse the repository at this point in the history
Change-Id: Ic65ff53ff31d4f7f5530fd416a2accd524cc1f3f
Reviewed-on: http://review.couchbase.org/78388
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
  • Loading branch information
trondn committed May 23, 2017
1 parent 527b768 commit 2115f7d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions protocol/connection/client_connection.cc
Expand Up @@ -216,7 +216,9 @@ SOCKET new_socket(std::string& host, in_port_t port, sa_family_t family) {
}

for (struct addrinfo* next = ai; next; next = next->ai_next) {
SOCKET sfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
SOCKET sfd = socket(next->ai_family,
next->ai_socktype,
next->ai_protocol);
if (sfd != INVALID_SOCKET) {

#ifdef WIN32
Expand All @@ -235,7 +237,7 @@ SOCKET new_socket(std::string& host, in_port_t port, sa_family_t family) {
}
#endif

if (connect(sfd, ai->ai_addr, ai->ai_addrlen) != SOCKET_ERROR) {
if (connect(sfd, next->ai_addr, next->ai_addrlen) != SOCKET_ERROR) {
freeaddrinfo(ai);
return sfd;
}
Expand Down

0 comments on commit 2115f7d

Please sign in to comment.