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

Side by Side Diff: base/sync_socket_win.cc

Issue 9316084: Switch back to 'int' instead of uint32 and call CancelIo before closing the socket handle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | content/renderer/media/audio_device.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 "base/sync_socket.h" 5 #include "base/sync_socket.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/win/scoped_handle.h" 8 #include "base/win/scoped_handle.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 COMPILE_ASSERT(sizeof(buffer[0]) == sizeof(char), incorrect_buffer_type); 119 COMPILE_ASSERT(sizeof(buffer[0]) == sizeof(char), incorrect_buffer_type);
120 DCHECK_LE(length, kMaxMessageLength); 120 DCHECK_LE(length, kMaxMessageLength);
121 121
122 OVERLAPPED ol = {0}; 122 OVERLAPPED ol = {0};
123 ol.hEvent = io_event->handle(); 123 ol.hEvent = io_event->handle();
124 size_t count = 0; 124 size_t count = 0;
125 while (count < length) { 125 while (count < length) {
126 DWORD chunk = GetNextChunkSize(count, length); 126 DWORD chunk = GetNextChunkSize(count, length);
127 // This is either the ReadFile or WriteFile call depending on whether 127 // This is either the ReadFile or WriteFile call depending on whether
128 // we're receiving or sending data. 128 // we're receiving or sending data.
129 DWORD len; 129 DWORD len = 0;
130 BOOL ok = operation(file, static_cast<BufferType*>(buffer) + count, chunk, 130 BOOL ok = operation(file, static_cast<BufferType*>(buffer) + count, chunk,
131 &len, &ol); 131 &len, &ol);
132 if (!ok) { 132 if (!ok) {
133 if (::GetLastError() == ERROR_IO_PENDING) { 133 if (::GetLastError() == ERROR_IO_PENDING) {
134 base::WaitableEvent* events[] = { io_event, cancel_event }; 134 base::WaitableEvent* events[] = { io_event, cancel_event };
135 size_t signaled = WaitableEvent::WaitMany(events, arraysize(events)); 135 size_t signaled = WaitableEvent::WaitMany(events, arraysize(events));
136 if (signaled == 1) { 136 if (signaled == 1) {
137 VLOG(1) << "Shutdown was signaled. Closing socket."; 137 VLOG(1) << "Shutdown was signaled. Closing socket.";
138 CancelIo(file);
138 socket->Close(); 139 socket->Close();
140 count = 0;
139 break; 141 break;
140 } else { 142 } else {
141 GetOverlappedResult(file, &ol, &len, TRUE); 143 GetOverlappedResult(file, &ol, &len, TRUE);
142 } 144 }
143 } else { 145 } else {
144 return (0 < count) ? count : 0; 146 return (0 < count) ? count : 0;
145 } 147 }
146 } 148 }
147 count += len; 149 count += len;
148 } 150 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 246 }
245 247
246 // static 248 // static
247 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, 249 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a,
248 CancelableSyncSocket* socket_b) { 250 CancelableSyncSocket* socket_b) {
249 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); 251 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true);
250 } 252 }
251 253
252 254
253 } // namespace base 255 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/audio_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698