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

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

Issue 22634003: Replaced strerror() calls with threadsafe strerror_r() (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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/dbg_connection_macos.cc ('k') | runtime/bin/eventhandler_linux.cc » ('j') | 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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 sd->fd(), 81 sd->fd(),
82 &event)); 82 &event));
83 } else { 83 } else {
84 status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, 84 status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_,
85 EPOLL_CTL_ADD, 85 EPOLL_CTL_ADD,
86 sd->fd(), 86 sd->fd(),
87 &event)); 87 &event));
88 sd->set_tracked_by_epoll(true); 88 sd->set_tracked_by_epoll(true);
89 } 89 }
90 if (status == -1) { 90 if (status == -1) {
91 FATAL1("Failed updating epoll instance: %s", strerror(errno)); 91 const int kBufferSize = 1024;
92 char error_message[kBufferSize];
93 strerror_r(errno, error_message, kBufferSize);
94 FATAL1("Failed updating epoll instance: %s", error_message);
92 } 95 }
93 } 96 }
94 } 97 }
95 98
96 99
97 EventHandlerImplementation::EventHandlerImplementation() 100 EventHandlerImplementation::EventHandlerImplementation()
98 : socket_map_(&HashMap::SamePointerValue, 16) { 101 : socket_map_(&HashMap::SamePointerValue, 16) {
99 intptr_t result; 102 intptr_t result;
100 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_)); 103 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_));
101 if (result != 0) { 104 if (result != 0) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // recv to peek for whether the other end of the socket 302 // recv to peek for whether the other end of the socket
300 // actually closed. 303 // actually closed.
301 char buffer; 304 char buffer;
302 ssize_t bytesPeeked = 305 ssize_t bytesPeeked =
303 TEMP_FAILURE_RETRY(recv(sd->fd(), &buffer, 1, MSG_PEEK)); 306 TEMP_FAILURE_RETRY(recv(sd->fd(), &buffer, 1, MSG_PEEK));
304 ASSERT(EAGAIN == EWOULDBLOCK); 307 ASSERT(EAGAIN == EWOULDBLOCK);
305 if (bytesPeeked == 0) { 308 if (bytesPeeked == 0) {
306 event_mask = (1 << kCloseEvent); 309 event_mask = (1 << kCloseEvent);
307 sd->MarkClosedRead(); 310 sd->MarkClosedRead();
308 } else if (errno != EWOULDBLOCK) { 311 } else if (errno != EWOULDBLOCK) {
309 Log::PrintErr("Error recv: %s\n", strerror(errno)); 312 const int kBufferSize = 1024;
313 char error_message[kBufferSize];
314 strerror_r(errno, error_message, kBufferSize);
315 Log::PrintErr("Error recv: %s\n", error_message);
310 } 316 }
311 } 317 }
312 } 318 }
313 } 319 }
314 320
315 // On pipes EPOLLHUP is reported without EPOLLIN when there is no 321 // On pipes EPOLLHUP is reported without EPOLLIN when there is no
316 // more data to read. 322 // more data to read.
317 if (sd->IsPipe()) { 323 if (sd->IsPipe()) {
318 if (((events & EPOLLIN) == 0) && 324 if (((events & EPOLLIN) == 0) &&
319 ((events & EPOLLHUP) != 0)) { 325 ((events & EPOLLHUP) != 0)) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 441
436 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 442 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
437 // The hashmap does not support keys with value 0. 443 // The hashmap does not support keys with value 0.
438 return dart::Utils::WordHash(fd + 1); 444 return dart::Utils::WordHash(fd + 1);
439 } 445 }
440 446
441 } // namespace bin 447 } // namespace bin
442 } // namespace dart 448 } // namespace dart
443 449
444 #endif // defined(TARGET_OS_ANDROID) 450 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/dbg_connection_macos.cc ('k') | runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698