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

Side by Side Diff: net/base/address_tracker_linux.cc

Issue 10910076: [net (linux)] Don't send OnIPAddressChanged when the AddressMap is first populated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/network_change_notifier_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/address_tracker_linux.h" 5 #include "net/base/address_tracker_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "base/eintr_wrapper.h" 9 #include "base/eintr_wrapper.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 rv = HANDLE_EINTR(sendto(sock, &request, request.header.nlmsg_len, 0, 134 rv = HANDLE_EINTR(sendto(sock, &request, request.header.nlmsg_len, 0,
135 reinterpret_cast<struct sockaddr*>(&peer), 135 reinterpret_cast<struct sockaddr*>(&peer),
136 sizeof(peer))); 136 sizeof(peer)));
137 if (rv < 0) { 137 if (rv < 0) {
138 PLOG(ERROR) << "Could not send NETLINK request"; 138 PLOG(ERROR) << "Could not send NETLINK request";
139 CloseSocket(sock); 139 CloseSocket(sock);
140 return; 140 return;
141 } 141 }
142 142
143 netlink_fd_ = sock; 143 netlink_fd_ = sock;
144
145 // Consume any pending messages to populate the AddressMap, but don't notify.
146 ReadMessages();
mmenke 2012/09/04 19:40:16 Since this is a non-blocking socket, is there a ch
szym 2012/09/04 20:10:59 I just tested this and it seems to be working as i
144 } 147 }
145 148
146 AddressTrackerLinux::AddressMap AddressTrackerLinux::GetAddressMap() const { 149 AddressTrackerLinux::AddressMap AddressTrackerLinux::GetAddressMap() const {
147 base::AutoLock lock(lock_); 150 base::AutoLock lock(lock_);
148 return map_; 151 return map_;
149 } 152 }
150 153
151 bool AddressTrackerLinux::ReadMessages() { 154 bool AddressTrackerLinux::ReadMessages() {
152 char buffer[4096]; 155 char buffer[4096];
153 bool changed = false; 156 bool changed = false;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void AddressTrackerLinux::OnFileCanReadWithoutBlocking(int fd) { 220 void AddressTrackerLinux::OnFileCanReadWithoutBlocking(int fd) {
218 DCHECK_EQ(netlink_fd_, fd); 221 DCHECK_EQ(netlink_fd_, fd);
219 if (ReadMessages()) 222 if (ReadMessages())
220 callback_.Run(); 223 callback_.Run();
221 } 224 }
222 225
223 void AddressTrackerLinux::OnFileCanWriteWithoutBlocking(int /* fd */) {} 226 void AddressTrackerLinux::OnFileCanWriteWithoutBlocking(int /* fd */) {}
224 227
225 } // namespace internal 228 } // namespace internal
226 } // namespace net 229 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/network_change_notifier_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698