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

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

Issue 100129: Add a histogram to measure how long are we waiting to close... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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) 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_win.h" 5 #include "net/base/tcp_client_socket_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory_debug.h" 9 #include "base/memory_debug.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // In most socket implementations, closing a socket results in a graceful 150 // In most socket implementations, closing a socket results in a graceful
151 // connection shutdown, but in Winsock we have to call shutdown explicitly. 151 // connection shutdown, but in Winsock we have to call shutdown explicitly.
152 // See the MSDN page "Graceful Shutdown, Linger Options, and Socket Closure" 152 // See the MSDN page "Graceful Shutdown, Linger Options, and Socket Closure"
153 // at http://msdn.microsoft.com/en-us/library/ms738547.aspx 153 // at http://msdn.microsoft.com/en-us/library/ms738547.aspx
154 shutdown(socket_, SD_SEND); 154 shutdown(socket_, SD_SEND);
155 155
156 // This cancels any pending IO. 156 // This cancels any pending IO.
157 closesocket(socket_); 157 closesocket(socket_);
158 socket_ = INVALID_SOCKET; 158 socket_ = INVALID_SOCKET;
159 159
160 // Wait for pending IO to be aborted. 160 if (waiting_read_ || waiting_write_) {
161 if (waiting_read_) 161 base::TimeTicks start = base::TimeTicks::Now();
162 WaitForSingleObject(read_overlapped_.hEvent, INFINITE); 162
163 if (waiting_write_) 163 // Wait for pending IO to be aborted.
164 WaitForSingleObject(write_overlapped_.hEvent, INFINITE); 164 if (waiting_read_)
165 WaitForSingleObject(read_overlapped_.hEvent, INFINITE);
166 if (waiting_write_)
167 WaitForSingleObject(write_overlapped_.hEvent, INFINITE);
168
169 // We want to see if we block the message loop for too long.
170 UMA_HISTOGRAM_TIMES("AsyncIO.ClientSocketDisconnect",
171 base::TimeTicks::Now() - start);
172 }
165 173
166 WSACloseEvent(read_overlapped_.hEvent); 174 WSACloseEvent(read_overlapped_.hEvent);
167 memset(&read_overlapped_, 0, sizeof(read_overlapped_)); 175 memset(&read_overlapped_, 0, sizeof(read_overlapped_));
168 WSACloseEvent(write_overlapped_.hEvent); 176 WSACloseEvent(write_overlapped_.hEvent);
169 memset(&write_overlapped_, 0, sizeof(write_overlapped_)); 177 memset(&write_overlapped_, 0, sizeof(write_overlapped_));
170 178
171 // Reset for next time. 179 // Reset for next time.
172 current_ai_ = addresses_.head(); 180 current_ai_ = addresses_.head();
173 181
174 waiting_read_ = false; 182 waiting_read_ = false;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 FALSE, &flags); 435 FALSE, &flags);
428 WSAResetEvent(object); 436 WSAResetEvent(object);
429 TRACE_EVENT_END("socket.write", tcp_socket_, 437 TRACE_EVENT_END("socket.write", tcp_socket_,
430 StringPrintf("%d bytes", num_bytes)); 438 StringPrintf("%d bytes", num_bytes));
431 tcp_socket_->waiting_write_ = false; 439 tcp_socket_->waiting_write_ = false;
432 tcp_socket_->DoWriteCallback( 440 tcp_socket_->DoWriteCallback(
433 ok ? num_bytes : MapWinsockError(WSAGetLastError())); 441 ok ? num_bytes : MapWinsockError(WSAGetLastError()));
434 } 442 }
435 443
436 } // namespace net 444 } // namespace net
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