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

Unified Diff: net/curvecp/client_packetizer.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/curvecp/client_packetizer.h ('k') | net/curvecp/curvecp_client_socket.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/curvecp/client_packetizer.cc
diff --git a/net/curvecp/client_packetizer.cc b/net/curvecp/client_packetizer.cc
index 4b75c6e7d57cfebfe4ff8206d3a85e40dc43390b..712a4e2c9feeea2243ec5bde57b3bb359705475b 100644
--- a/net/curvecp/client_packetizer.cc
+++ b/net/curvecp/client_packetizer.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
-#include "net/base/sys_addrinfo.h"
#include "net/curvecp/protocol.h"
#include "net/udp/udp_client_socket.h"
@@ -33,7 +32,7 @@ ClientPacketizer::ClientPacketizer()
: Packetizer(),
next_state_(NONE),
listener_(NULL),
- current_address_(NULL),
+ current_address_index_(-1),
hello_attempts_(0),
initiate_sent_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(
@@ -290,25 +289,17 @@ void ClientPacketizer::DoCallback(int result) {
int ClientPacketizer::ConnectNextAddress() {
// TODO(mbelshe): plumb Netlog information
- DCHECK(addresses_.head());
+ DCHECK(!addresses_.empty());
socket_.reset(new UDPClientSocket(DatagramSocket::DEFAULT_BIND,
RandIntCallback(),
NULL,
NetLog::Source()));
- // Rotate to next address in the list.
- if (current_address_)
- current_address_ = current_address_->ai_next;
- if (!current_address_)
- current_address_ = addresses_.head();
+ // Rotate to next address in the list. Note, this sets it to 0 on first call.
+ current_address_index_ = (current_address_index_ + 1) % addresses_.size();
- IPEndPoint endpoint;
- if (!endpoint.FromSockAddr(current_address_->ai_addr,
- current_address_->ai_addrlen))
- return ERR_FAILED;
-
- int rv = socket_->Connect(endpoint);
+ int rv = socket_->Connect(addresses_[current_address_index_]);
DCHECK_NE(ERR_IO_PENDING, rv);
return rv;
« no previous file with comments | « net/curvecp/client_packetizer.h ('k') | net/curvecp/curvecp_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698