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

Side by Side Diff: remoting/jingle_glue/chromium_socket_factory.cc

Issue 10827064: Ignore ERR_ADDRESS_INVALID error returned from sendto(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | no next file » | 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 "remoting/jingle_glue/chromium_socket_factory.h" 5 #include "remoting/jingle_glue/chromium_socket_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "jingle/glue/utils.h" 10 #include "jingle/glue/utils.h"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "net/base/ip_endpoint.h" 12 #include "net/base/ip_endpoint.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/udp/udp_server_socket.h" 14 #include "net/udp/udp_server_socket.h"
15 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h" 15 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 18
19 namespace { 19 namespace {
20 20
21 // Size of the buffer to allocate for RecvFrom(). 21 // Size of the buffer to allocate for RecvFrom().
22 const int kReceiveBufferSize = 65536; 22 const int kReceiveBufferSize = 65536;
23 23
24 // Maximum amount of data in the send buffers. This is necessary to 24 // Maximum amount of data in the send buffers. This is necessary to
25 // prevent out-of-memory crashes if the caller sends data faster than 25 // prevent out-of-memory crashes if the caller sends data faster than
26 // Pepper's UDP API can handle it. This maximum should never be 26 // Pepper's UDP API can handle it. This maximum should never be
27 // reached under normal conditions. 27 // reached under normal conditions.
28 const int kMaxSendBufferSize = 256 * 1024; 28 const int kMaxSendBufferSize = 256 * 1024;
29 29
30 // Defines set of transient errors. These errors are ignored when we get them
31 // from sendto() calls.
32 bool IsTransientError(int error) {
33 return error == net::ERR_ADDRESS_UNREACHABLE ||
34 error == net::ERR_ADDRESS_INVALID;
35 }
36
30 class UdpPacketSocket : public talk_base::AsyncPacketSocket { 37 class UdpPacketSocket : public talk_base::AsyncPacketSocket {
31 public: 38 public:
32 UdpPacketSocket(); 39 UdpPacketSocket();
33 virtual ~UdpPacketSocket(); 40 virtual ~UdpPacketSocket();
34 41
35 bool Init(const talk_base::SocketAddress& local_address, 42 bool Init(const talk_base::SocketAddress& local_address,
36 int min_port, int max_port); 43 int min_port, int max_port);
37 44
38 // talk_base::AsyncPacketSocket interface. 45 // talk_base::AsyncPacketSocket interface.
39 virtual talk_base::SocketAddress GetLocalAddress() const; 46 virtual talk_base::SocketAddress GetLocalAddress() const;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 send_pending_ = true; 264 send_pending_ = true;
258 } else { 265 } else {
259 OnSendCompleted(result); 266 OnSendCompleted(result);
260 } 267 }
261 } 268 }
262 269
263 void UdpPacketSocket::OnSendCompleted(int result) { 270 void UdpPacketSocket::OnSendCompleted(int result) {
264 send_pending_ = false; 271 send_pending_ = false;
265 272
266 if (result < 0) { 273 if (result < 0) {
267 // Treat all errors except ERR_ADDRESS_UNREACHABLE as fatal. 274 if (!IsTransientError(result)) {
268 if (result != net::ERR_ADDRESS_UNREACHABLE) {
269 LOG(ERROR) << "Send failed on a UDP socket: " << result; 275 LOG(ERROR) << "Send failed on a UDP socket: " << result;
270 error_ = EINVAL; 276 error_ = EINVAL;
271 return; 277 return;
272 } 278 }
273 } 279 }
274 280
275 // Don't need to worry about partial sends because this is a datagram 281 // Don't need to worry about partial sends because this is a datagram
276 // socket. 282 // socket.
277 send_queue_size_ -= send_queue_.front().data->size(); 283 send_queue_size_ -= send_queue_.front().data->size();
278 send_queue_.pop_front(); 284 send_queue_.pop_front();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 const talk_base::SocketAddress& remote_address, 354 const talk_base::SocketAddress& remote_address,
349 const talk_base::ProxyInfo& proxy_info, 355 const talk_base::ProxyInfo& proxy_info,
350 const std::string& user_agent, 356 const std::string& user_agent,
351 bool ssl) { 357 bool ssl) {
352 // We don't use TCP sockets for remoting connections. 358 // We don't use TCP sockets for remoting connections.
353 NOTREACHED(); 359 NOTREACHED();
354 return NULL; 360 return NULL;
355 } 361 }
356 362
357 } // namespace remoting 363 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698