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

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

Issue 174033002: Add missing mutex protection for timeout queue with mutex (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add a couple of ASSERTs Created 6 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 | « runtime/bin/eventhandler.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) 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_LINUX) 6 #if defined(TARGET_OS_LINUX)
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (events & EPOLLOUT) event_mask |= (1 << kOutEvent); 124 if (events & EPOLLOUT) event_mask |= (1 << kOutEvent);
125 if (events & (EPOLLHUP | EPOLLRDHUP)) event_mask |= (1 << kCloseEvent); 125 if (events & (EPOLLHUP | EPOLLRDHUP)) event_mask |= (1 << kCloseEvent);
126 return event_mask; 126 return event_mask;
127 } 127 }
128 128
129 129
130 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, 130 void EventHandlerImplementation::HandleEvents(struct epoll_event* events,
131 int size) { 131 int size) {
132 for (int i = 0; i < size; i++) { 132 for (int i = 0; i < size; i++) {
133 uint64_t data = events[i].data.u64; 133 uint64_t data = events[i].data.u64;
134 // ILLEGAL_PORT is used to identify timer-fd.
134 if (data == ILLEGAL_PORT) { 135 if (data == ILLEGAL_PORT) {
135 int64_t val; 136 int64_t val;
136 VOID_TEMP_FAILURE_RETRY(read(timer_fd_, &val, sizeof(val))); 137 VOID_TEMP_FAILURE_RETRY(read(timer_fd_, &val, sizeof(val)));
138 timer_mutex_.Lock();
137 if (timeout_queue_.HasTimeout()) { 139 if (timeout_queue_.HasTimeout()) {
138 DartUtils::PostNull(timeout_queue_.CurrentPort()); 140 DartUtils::PostNull(timeout_queue_.CurrentPort());
139 timeout_queue_.RemoveCurrent(); 141 timeout_queue_.RemoveCurrent();
140 } 142 }
143 timer_mutex_.Unlock();
141 } else { 144 } else {
142 int32_t event_mask = GetPollEvents(events[i].events); 145 int32_t event_mask = GetPollEvents(events[i].events);
143 if (event_mask != 0) { 146 if (event_mask != 0) {
144 Dart_Port port = data; 147 Dart_Port port = data;
145 ASSERT(port != 0); 148 ASSERT(port != 0);
146 DartUtils::PostInt32(port, event_mask); 149 DartUtils::PostInt32(port, event_mask);
147 } 150 }
148 } 151 }
149 } 152 }
150 } 153 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // Add to epoll - this is the first time we see it. 232 // Add to epoll - this is the first time we see it.
230 AddToEpollInstance(epoll_fd_, id, dart_port, data); 233 AddToEpollInstance(epoll_fd_, id, dart_port, data);
231 } 234 }
232 } 235 }
233 } 236 }
234 237
235 } // namespace bin 238 } // namespace bin
236 } // namespace dart 239 } // namespace dart
237 240
238 #endif // defined(TARGET_OS_LINUX) 241 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698