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

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

Issue 82943004: Revert using one-shot on mac, as it doesn't work as expected. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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) 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 } 72 }
73 73
74 74
75 // Update the kqueue registration for SocketData structure to reflect 75 // Update the kqueue registration for SocketData structure to reflect
76 // the events currently of interest. 76 // the events currently of interest.
77 static void UpdateKqueue(intptr_t kqueue_fd_, SocketData* sd) { 77 static void UpdateKqueue(intptr_t kqueue_fd_, SocketData* sd) {
78 static const intptr_t kMaxChanges = 2; 78 static const intptr_t kMaxChanges = 2;
79 intptr_t changes = 0; 79 intptr_t changes = 0;
80 struct kevent events[kMaxChanges]; 80 struct kevent events[kMaxChanges];
81 // Only report events once and wait for them to be re-enabled after the
82 // event has been handled by the Dart code. This is done by using EV_ONESHOT.
83 if (sd->port() != 0) { 81 if (sd->port() != 0) {
84 // Register or unregister READ filter if needed. 82 // Register or unregister READ filter if needed.
85 if (sd->HasReadEvent()) { 83 if (sd->HasReadEvent()) {
86 if (!sd->read_tracked_by_kqueue()) { 84 if (!sd->read_tracked_by_kqueue()) {
87 EV_SET(events + changes, 85 EV_SET(events + changes, sd->fd(), EVFILT_READ, EV_ADD, 0, 0, sd);
88 sd->fd(),
89 EVFILT_READ,
90 EV_ADD | EV_ONESHOT,
91 0,
92 0,
93 sd);
94 ++changes; 86 ++changes;
95 sd->set_read_tracked_by_kqueue(true); 87 sd->set_read_tracked_by_kqueue(true);
96 } 88 }
97 } else if (sd->read_tracked_by_kqueue()) { 89 } else if (sd->read_tracked_by_kqueue()) {
98 EV_SET(events + changes, sd->fd(), EVFILT_READ, EV_DELETE, 0, 0, NULL); 90 EV_SET(events + changes, sd->fd(), EVFILT_READ, EV_DELETE, 0, 0, NULL);
99 ++changes; 91 ++changes;
100 sd->set_read_tracked_by_kqueue(false); 92 sd->set_read_tracked_by_kqueue(false);
101 } 93 }
102 // Register or unregister WRITE filter if needed. 94 // Register or unregister WRITE filter if needed.
103 if (sd->HasWriteEvent()) { 95 if (sd->HasWriteEvent()) {
104 if (!sd->write_tracked_by_kqueue()) { 96 if (!sd->write_tracked_by_kqueue()) {
105 EV_SET(events + changes, 97 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_ADD, 0, 0, sd);
106 sd->fd(),
107 EVFILT_WRITE,
108 EV_ADD | EV_ONESHOT,
109 0,
110 0,
111 sd);
112 ++changes; 98 ++changes;
113 sd->set_write_tracked_by_kqueue(true); 99 sd->set_write_tracked_by_kqueue(true);
114 } 100 }
115 } else if (sd->write_tracked_by_kqueue()) { 101 } else if (sd->write_tracked_by_kqueue()) {
116 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, NULL); 102 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
117 ++changes; 103 ++changes;
118 sd->set_write_tracked_by_kqueue(false); 104 sd->set_write_tracked_by_kqueue(false);
119 } 105 }
120 } 106 }
121 if (changes > 0) { 107 if (changes > 0) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if ((events[i].flags & EV_ERROR) != 0) { 335 if ((events[i].flags & EV_ERROR) != 0) {
350 const int kBufferSize = 1024; 336 const int kBufferSize = 1024;
351 char error_message[kBufferSize]; 337 char error_message[kBufferSize];
352 strerror_r(events[i].data, error_message, kBufferSize); 338 strerror_r(events[i].data, error_message, kBufferSize);
353 FATAL1("kevent failed %s\n", error_message); 339 FATAL1("kevent failed %s\n", error_message);
354 } 340 }
355 if (events[i].udata == NULL) { 341 if (events[i].udata == NULL) {
356 interrupt_seen = true; 342 interrupt_seen = true;
357 } else { 343 } else {
358 SocketData* sd = reinterpret_cast<SocketData*>(events[i].udata); 344 SocketData* sd = reinterpret_cast<SocketData*>(events[i].udata);
359 sd->set_read_tracked_by_kqueue(false); 345 RemoveFromKqueue(kqueue_fd_, sd);
360 sd->set_write_tracked_by_kqueue(false);
361 intptr_t event_mask = GetEvents(events + i, sd); 346 intptr_t event_mask = GetEvents(events + i, sd);
362 if (event_mask != 0) { 347 if (event_mask != 0) {
363 Dart_Port port = sd->port(); 348 Dart_Port port = sd->port();
364 ASSERT(port != 0); 349 ASSERT(port != 0);
365 DartUtils::PostInt32(port, event_mask); 350 DartUtils::PostInt32(port, event_mask);
366 } 351 }
367 } 352 }
368 } 353 }
369 if (interrupt_seen) { 354 if (interrupt_seen) {
370 // Handle after socket events, so we avoid closing a socket before we handle 355 // Handle after socket events, so we avoid closing a socket before we handle
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 450
466 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 451 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
467 // The hashmap does not support keys with value 0. 452 // The hashmap does not support keys with value 0.
468 return dart::Utils::WordHash(fd + 1); 453 return dart::Utils::WordHash(fd + 1);
469 } 454 }
470 455
471 } // namespace bin 456 } // namespace bin
472 } // namespace dart 457 } // namespace dart
473 458
474 #endif // defined(TARGET_OS_MACOS) 459 #endif // defined(TARGET_OS_MACOS)
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