| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/udp/udp_socket_win.h" | 5 #include "net/udp/udp_socket_win.h" |
| 6 | 6 |
| 7 #include <mstcpip.h> | 7 #include <mstcpip.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" |
| 11 #include "base/memory/memory_debug.h" | |
| 12 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 13 #include "base/metrics/stats_counters.h" | 12 #include "base/metrics/stats_counters.h" |
| 14 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 15 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 16 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
| 17 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 18 #include "net/base/net_log.h" | 17 #include "net/base/net_log.h" |
| 19 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 20 #include "net/base/winsock_init.h" | 19 #include "net/base/winsock_init.h" |
| 21 #include "net/base/winsock_util.h" | 20 #include "net/base/winsock_util.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 read_buffer.buf = buf->data(); | 316 read_buffer.buf = buf->data(); |
| 318 read_buffer.len = buf_len; | 317 read_buffer.len = buf_len; |
| 319 | 318 |
| 320 DWORD flags = 0; | 319 DWORD flags = 0; |
| 321 DWORD num; | 320 DWORD num; |
| 322 AssertEventNotSignaled(read_overlapped_.hEvent); | 321 AssertEventNotSignaled(read_overlapped_.hEvent); |
| 323 int rv = WSARecvFrom(socket_, &read_buffer, 1, &num, &flags, addr, | 322 int rv = WSARecvFrom(socket_, &read_buffer, 1, &num, &flags, addr, |
| 324 &recv_addr_len_, &read_overlapped_, NULL); | 323 &recv_addr_len_, &read_overlapped_, NULL); |
| 325 if (rv == 0) { | 324 if (rv == 0) { |
| 326 if (ResetEventIfSignaled(read_overlapped_.hEvent)) { | 325 if (ResetEventIfSignaled(read_overlapped_.hEvent)) { |
| 327 // Because of how WSARecv fills memory when used asynchronously, Purify | |
| 328 // isn't able to detect that it's been initialized, so it scans for 0xcd | |
| 329 // in the buffer and reports UMRs (uninitialized memory reads) for those | |
| 330 // individual bytes. We override that in PURIFY builds to avoid the | |
| 331 // false error reports. | |
| 332 // See bug 5297. | |
| 333 base::MemoryDebug::MarkAsInitialized(read_buffer.buf, num); | |
| 334 if (!ProcessSuccessfulRead(num, address)) | 326 if (!ProcessSuccessfulRead(num, address)) |
| 335 return ERR_FAILED; | 327 return ERR_FAILED; |
| 336 return static_cast<int>(num); | 328 return static_cast<int>(num); |
| 337 } | 329 } |
| 338 } else { | 330 } else { |
| 339 int os_error = WSAGetLastError(); | 331 int os_error = WSAGetLastError(); |
| 340 if (os_error != WSA_IO_PENDING) | 332 if (os_error != WSA_IO_PENDING) |
| 341 return MapSystemError(os_error); | 333 return MapSystemError(os_error); |
| 342 } | 334 } |
| 343 read_watcher_.StartWatching(read_overlapped_.hEvent, &read_delegate_); | 335 read_watcher_.StartWatching(read_overlapped_.hEvent, &read_delegate_); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 393 |
| 402 for (int i = 0; i < kBindRetries; ++i) { | 394 for (int i = 0; i < kBindRetries; ++i) { |
| 403 int rv = DoBind(IPEndPoint(ip, rand_int_cb_.Run(kPortStart, kPortEnd))); | 395 int rv = DoBind(IPEndPoint(ip, rand_int_cb_.Run(kPortStart, kPortEnd))); |
| 404 if (rv == OK || rv != ERR_ADDRESS_IN_USE) | 396 if (rv == OK || rv != ERR_ADDRESS_IN_USE) |
| 405 return rv; | 397 return rv; |
| 406 } | 398 } |
| 407 return DoBind(IPEndPoint(ip, 0)); | 399 return DoBind(IPEndPoint(ip, 0)); |
| 408 } | 400 } |
| 409 | 401 |
| 410 } // namespace net | 402 } // namespace net |
| OLD | NEW |