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

Side by Side Diff: runtime/bin/eventhandler_win.cc

Issue 315003002: Fix double-closing of handles in Windows EventHandler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « runtime/bin/eventhandler_win.h ('k') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <winsock2.h> // NOLINT 10 #include <winsock2.h> // NOLINT
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 EventHandlerImplementation* event_handler) { 381 EventHandlerImplementation* event_handler) {
382 ScopedLock lock(this); 382 ScopedLock lock(this);
383 event_handler_ = event_handler; 383 event_handler_ = event_handler;
384 if (completion_port_ == INVALID_HANDLE_VALUE) { 384 if (completion_port_ == INVALID_HANDLE_VALUE) {
385 CreateCompletionPort(event_handler_->completion_port()); 385 CreateCompletionPort(event_handler_->completion_port());
386 } 386 }
387 } 387 }
388 388
389 389
390 bool DirectoryWatchHandle::IsClosed() { 390 bool DirectoryWatchHandle::IsClosed() {
391 return IsClosing() && pending_read_ == NULL; 391 return IsClosing() && pending_read_ == NULL && closed_;
392 }
393
kasperl 2014/06/04 11:37:54 Extra newline here.
394 void DirectoryWatchHandle::DoClose() {
395 if (handle_ != INVALID_HANDLE_VALUE) {
396 Handle::DoClose();
397 }
398 closed_ = true;
392 } 399 }
393 400
394 401
395 bool DirectoryWatchHandle::IssueRead() { 402 bool DirectoryWatchHandle::IssueRead() {
396 ScopedLock lock(this); 403 ScopedLock lock(this);
397 // It may have been started before, as we start the directory-handler when 404 // It may have been started before, as we start the directory-handler when
398 // we create it. 405 // we create it.
399 if (pending_read_ != NULL) return true; 406 if (pending_read_ != NULL) return true;
400 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(kBufferSize); 407 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(kBufferSize);
401 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); 408 ASSERT(completion_port_ != INVALID_HANDLE_VALUE);
(...skipping 15 matching lines...) Expand all
417 } 424 }
418 425
419 426
420 void DirectoryWatchHandle::Stop() { 427 void DirectoryWatchHandle::Stop() {
421 ScopedLock lock(this); 428 ScopedLock lock(this);
422 // Stop the outstanding read, so we can close the handle. 429 // Stop the outstanding read, so we can close the handle.
423 430
424 if (pending_read_ != NULL) { 431 if (pending_read_ != NULL) {
425 CancelIoEx(handle(), pending_read_->GetCleanOverlapped()); 432 CancelIoEx(handle(), pending_read_->GetCleanOverlapped());
426 // Don't dispose of the buffer, as it will still complete (with length 0). 433 // Don't dispose of the buffer, as it will still complete (with length 0).
427 pending_read_ = NULL;
428 } 434 }
429 435
430 CloseHandle(handle()); 436 // Close handle, but don't mark as closed_.
kasperl 2014/06/04 11:37:54 closed_ -> closed.
431 handle_ = (INVALID_HANDLE_VALUE); 437 MarkClosing();
438 Handle::DoClose();
432 } 439 }
433 440
434 441
435 void SocketHandle::HandleIssueError() { 442 void SocketHandle::HandleIssueError() {
436 int error = WSAGetLastError(); 443 int error = WSAGetLastError();
437 if (error == WSAECONNRESET) { 444 if (error == WSAECONNRESET) {
438 HandleClosed(this); 445 HandleClosed(this);
439 } else { 446 } else {
440 HandleError(this); 447 HandleError(this);
441 } 448 }
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1370
1364 1371
1365 void EventHandlerImplementation::Shutdown() { 1372 void EventHandlerImplementation::Shutdown() {
1366 SendData(kShutdownId, 0, 0); 1373 SendData(kShutdownId, 0, 0);
1367 } 1374 }
1368 1375
1369 } // namespace bin 1376 } // namespace bin
1370 } // namespace dart 1377 } // namespace dart
1371 1378
1372 #endif // defined(TARGET_OS_WINDOWS) 1379 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698