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

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

Issue 13331: Add a call to MemoryDebug::MarkAsInitialized to the new network code to avoid... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/tcp_client_socket.h" 5 #include "net/base/tcp_client_socket.h"
6 6
7 #include "base/memory_debug.h"
7 #include "base/string_util.h" 8 #include "base/string_util.h"
8 #include "base/trace_event.h" 9 #include "base/trace_event.h"
9 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
10 #include "net/base/winsock_init.h" 11 #include "net/base/winsock_init.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 //----------------------------------------------------------------------------- 15 //-----------------------------------------------------------------------------
15 16
16 static int MapWinsockError(DWORD err) { 17 static int MapWinsockError(DWORD err) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 TRACE_EVENT_BEGIN("socket.read", this, ""); 169 TRACE_EVENT_BEGIN("socket.read", this, "");
169 // TODO(wtc): Remove the CHECKs after enough testing. 170 // TODO(wtc): Remove the CHECKs after enough testing.
170 CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_TIMEOUT); 171 CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_TIMEOUT);
171 DWORD num, flags = 0; 172 DWORD num, flags = 0;
172 int rv = WSARecv(socket_, &buffer_, 1, &num, &flags, &overlapped_, NULL); 173 int rv = WSARecv(socket_, &buffer_, 1, &num, &flags, &overlapped_, NULL);
173 if (rv == 0) { 174 if (rv == 0) {
174 CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_OBJECT_0); 175 CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_OBJECT_0);
175 BOOL ok = WSAResetEvent(overlapped_.hEvent); 176 BOOL ok = WSAResetEvent(overlapped_.hEvent);
176 CHECK(ok); 177 CHECK(ok);
177 TRACE_EVENT_END("socket.read", this, StringPrintf("%d bytes", num)); 178 TRACE_EVENT_END("socket.read", this, StringPrintf("%d bytes", num));
179
180 // Because of how WSARecv fills memory when used asynchronously, Purify
181 // isn't able to detect that it's been initialized, so it scans for 0xcd
182 // in the buffer and reports UMRs (uninitialized memory reads) for those
183 // individual bytes. We override that in PURIFY builds to avoid the false
184 // error reports.
185 // See http://code.google.com/p/chromium/issues/detail?id=5297
darin (slow to review) 2008/12/10 17:33:29 Can we use a more abbreviated way of referring to
186 base::MemoryDebug::MarkAsInitialized(buffer_.buf, num);
178 return static_cast<int>(num); 187 return static_cast<int>(num);
179 } 188 }
180 int err = WSAGetLastError(); 189 int err = WSAGetLastError();
181 if (err == WSA_IO_PENDING) { 190 if (err == WSA_IO_PENDING) {
182 watcher_.StartWatching(overlapped_.hEvent, this); 191 watcher_.StartWatching(overlapped_.hEvent, this);
183 wait_state_ = WAITING_READ; 192 wait_state_ = WAITING_READ;
184 callback_ = callback; 193 callback_ = callback;
185 return ERR_IO_PENDING; 194 return ERR_IO_PENDING;
186 } 195 }
187 return MapWinsockError(err); 196 return MapWinsockError(err);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 DidCompleteIO(); 358 DidCompleteIO();
350 break; 359 break;
351 default: 360 default:
352 NOTREACHED(); 361 NOTREACHED();
353 break; 362 break;
354 } 363 }
355 } 364 }
356 365
357 } // namespace net 366 } // namespace net
358 367
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