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

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

Issue 9361032: Fix event handler assert stupidity. :-) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 | 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 "bin/eventhandler.h" 5 #include "bin/eventhandler.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 EV_SET(events + changes, sd->fd(), EVFILT_READ, EV_DELETE, 0, 0, NULL); 52 EV_SET(events + changes, sd->fd(), EVFILT_READ, EV_DELETE, 0, 0, NULL);
53 ++changes; 53 ++changes;
54 sd->set_read_tracked_by_kqueue(false); 54 sd->set_read_tracked_by_kqueue(false);
55 } 55 }
56 if (sd->write_tracked_by_kqueue()) { 56 if (sd->write_tracked_by_kqueue()) {
57 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, sd); 57 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, sd);
58 ++changes; 58 ++changes;
59 sd->set_write_tracked_by_kqueue(false); 59 sd->set_write_tracked_by_kqueue(false);
60 } 60 }
61 if (changes > 0) { 61 if (changes > 0) {
62 ASSERT(changes < kMaxChanges); 62 ASSERT(changes <= kMaxChanges);
63 int status = 63 int status =
64 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, events, changes, NULL, 0, NULL)); 64 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, events, changes, NULL, 0, NULL));
65 if (status == -1) { 65 if (status == -1) {
66 FATAL("Failed deleting events from kqueue"); 66 FATAL("Failed deleting events from kqueue");
67 } 67 }
68 } 68 }
69 } 69 }
70 70
71 71
72 // Update the kqueue registration for SocketData structure to reflect 72 // Update the kqueue registration for SocketData structure to reflect
(...skipping 22 matching lines...) Expand all
95 ++changes; 95 ++changes;
96 sd->set_write_tracked_by_kqueue(true); 96 sd->set_write_tracked_by_kqueue(true);
97 } 97 }
98 } else if (sd->write_tracked_by_kqueue()) { 98 } else if (sd->write_tracked_by_kqueue()) {
99 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, NULL); 99 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
100 ++changes; 100 ++changes;
101 sd->set_write_tracked_by_kqueue(false); 101 sd->set_write_tracked_by_kqueue(false);
102 } 102 }
103 } 103 }
104 if (changes > 0) { 104 if (changes > 0) {
105 ASSERT(changes < kMaxChanges); 105 ASSERT(changes <= kMaxChanges);
106 int status = 106 int status =
107 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, events, changes, NULL, 0, NULL)); 107 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, events, changes, NULL, 0, NULL));
108 if (status == -1) { 108 if (status == -1) {
109 FATAL("Failed updating kqueue"); 109 FATAL("Failed updating kqueue");
110 } 110 }
111 } 111 }
112 } 112 }
113 113
114 114
115 EventHandlerImplementation::EventHandlerImplementation() 115 EventHandlerImplementation::EventHandlerImplementation()
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { 390 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) {
391 // The hashmap does not support keys with value 0. 391 // The hashmap does not support keys with value 0.
392 return reinterpret_cast<void*>(fd + 1); 392 return reinterpret_cast<void*>(fd + 1);
393 } 393 }
394 394
395 395
396 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 396 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
397 // The hashmap does not support keys with value 0. 397 // The hashmap does not support keys with value 0.
398 return dart::Utils::WordHash(fd + 1); 398 return dart::Utils::WordHash(fd + 1);
399 } 399 }
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