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

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

Issue 2495003003: Adds some error handling to the socket implementation. (Closed)
Patch Set: Add perror calls for fcntl Created 4 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
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/fdutils_android.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 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(TARGET_OS_MACOS) 8 #if defined(TARGET_OS_MACOS)
9 9
10 #include "bin/eventhandler.h" 10 #include "bin/eventhandler.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 100
101 EventHandlerImplementation::EventHandlerImplementation() 101 EventHandlerImplementation::EventHandlerImplementation()
102 : socket_map_(&HashMap::SamePointerValue, 16) { 102 : socket_map_(&HashMap::SamePointerValue, 16) {
103 intptr_t result; 103 intptr_t result;
104 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_)); 104 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_));
105 if (result != 0) { 105 if (result != 0) {
106 FATAL("Pipe creation failed"); 106 FATAL("Pipe creation failed");
107 } 107 }
108 FDUtils::SetNonBlocking(interrupt_fds_[0]); 108 if (!FDUtils::SetNonBlocking(interrupt_fds_[0])) {
109 FDUtils::SetCloseOnExec(interrupt_fds_[0]); 109 FATAL("Failed to set pipe fd non-blocking\n");
110 FDUtils::SetCloseOnExec(interrupt_fds_[1]); 110 }
111 if (!FDUtils::SetCloseOnExec(interrupt_fds_[0])) {
112 FATAL("Failed to set pipe fd close on exec\n");
113 }
114 if (!FDUtils::SetCloseOnExec(interrupt_fds_[1])) {
115 FATAL("Failed to set pipe fd close on exec\n");
116 }
111 shutdown_ = false; 117 shutdown_ = false;
112 118
113 kqueue_fd_ = NO_RETRY_EXPECTED(kqueue()); 119 kqueue_fd_ = NO_RETRY_EXPECTED(kqueue());
114 if (kqueue_fd_ == -1) { 120 if (kqueue_fd_ == -1) {
115 FATAL("Failed creating kqueue"); 121 FATAL("Failed creating kqueue");
116 } 122 }
117 FDUtils::SetCloseOnExec(kqueue_fd_); 123 if (!FDUtils::SetCloseOnExec(kqueue_fd_)) {
124 FATAL("Failed to set kqueue fd close on exec\n");
125 }
118 // Register the interrupt_fd with the kqueue. 126 // Register the interrupt_fd with the kqueue.
119 struct kevent event; 127 struct kevent event;
120 EV_SET(&event, interrupt_fds_[0], EVFILT_READ, EV_ADD, 0, 0, NULL); 128 EV_SET(&event, interrupt_fds_[0], EVFILT_READ, EV_ADD, 0, 0, NULL);
121 int status = NO_RETRY_EXPECTED(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL)); 129 int status = NO_RETRY_EXPECTED(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL));
122 if (status == -1) { 130 if (status == -1) {
123 const int kBufferSize = 1024; 131 const int kBufferSize = 1024;
124 char error_message[kBufferSize]; 132 char error_message[kBufferSize];
125 Utils::StrError(errno, error_message, kBufferSize); 133 Utils::StrError(errno, error_message, kBufferSize);
126 FATAL1("Failed adding interrupt fd to kqueue: %s\n", error_message); 134 FATAL1("Failed adding interrupt fd to kqueue: %s\n", error_message);
127 } 135 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // The hashmap does not support keys with value 0. 506 // The hashmap does not support keys with value 0.
499 return dart::Utils::WordHash(fd + 1); 507 return dart::Utils::WordHash(fd + 1);
500 } 508 }
501 509
502 } // namespace bin 510 } // namespace bin
503 } // namespace dart 511 } // namespace dart
504 512
505 #endif // defined(TARGET_OS_MACOS) 513 #endif // defined(TARGET_OS_MACOS)
506 514
507 #endif // !defined(DART_IO_DISABLED) 515 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/fdutils_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698