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

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

Issue 12476021: Handle /dev/null on linux, as an closed device. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Apply same fix for mac Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, NULL); 95 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
96 ++changes; 96 ++changes;
97 sd->set_write_tracked_by_kqueue(false); 97 sd->set_write_tracked_by_kqueue(false);
98 } 98 }
99 } 99 }
100 if (changes > 0) { 100 if (changes > 0) {
101 ASSERT(changes <= kMaxChanges); 101 ASSERT(changes <= kMaxChanges);
102 int status = 102 int status =
103 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, events, changes, NULL, 0, NULL)); 103 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, events, changes, NULL, 0, NULL));
104 if (status == -1) { 104 if (status == -1) {
105 FATAL1("Failed updating kqueue: %s\n", strerror(errno)); 105 // kQueue does not accept the file descriptor. It could be due to
106 // already closed file descriptor, or unuspported devices, such
107 // as /dev/null. In such case, mark the file descriptor as closed,
108 // so dart will handle it accordingly.
109 sd->set_write_tracked_by_kqueue(false);
110 sd->set_read_tracked_by_kqueue(false);
111 sd->ShutdownRead();
112 sd->ShutdownWrite();
113 DartUtils::PostInt32(sd->port(), 1 << kCloseEvent);
106 } 114 }
107 } 115 }
108 } 116 }
109 117
110 118
111 EventHandlerImplementation::EventHandlerImplementation() 119 EventHandlerImplementation::EventHandlerImplementation()
112 : socket_map_(&HashMap::SamePointerValue, 16) { 120 : socket_map_(&HashMap::SamePointerValue, 16) {
113 intptr_t result; 121 intptr_t result;
114 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_)); 122 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_));
115 if (result != 0) { 123 if (result != 0) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 return reinterpret_cast<void*>(fd + 1); 427 return reinterpret_cast<void*>(fd + 1);
420 } 428 }
421 429
422 430
423 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 431 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
424 // The hashmap does not support keys with value 0. 432 // The hashmap does not support keys with value 0.
425 return dart::Utils::WordHash(fd + 1); 433 return dart::Utils::WordHash(fd + 1);
426 } 434 }
427 435
428 #endif // defined(TARGET_OS_MACOS) 436 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698