| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "base/logging.h" | 28 #include "base/logging.h" |
| 29 #include "base/mac/mach_logging.h" | 29 #include "base/mac/mach_logging.h" |
| 30 #include "base/mac/scoped_mach_port.h" | 30 #include "base/mac/scoped_mach_port.h" |
| 31 #include "base/posix/eintr_wrapper.h" | 31 #include "base/posix/eintr_wrapper.h" |
| 32 #include "base/rand_util.h" | 32 #include "base/rand_util.h" |
| 33 #include "base/strings/stringprintf.h" | 33 #include "base/strings/stringprintf.h" |
| 34 #include "util/file/fd_io.h" | 34 #include "util/file/fd_io.h" |
| 35 #include "util/mach/child_port.h" | 35 #include "util/mach/child_port.h" |
| 36 #include "util/mach/mach_extensions.h" | 36 #include "util/mach/mach_extensions.h" |
| 37 #include "util/mach/mach_message.h" |
| 37 #include "util/mach/mach_message_server.h" | 38 #include "util/mach/mach_message_server.h" |
| 38 | 39 |
| 39 namespace crashpad { | 40 namespace crashpad { |
| 40 | 41 |
| 41 ChildPortHandshake::ChildPortHandshake() | 42 ChildPortHandshake::ChildPortHandshake() |
| 42 : token_(0), | 43 : token_(0), |
| 43 pipe_read_(), | 44 pipe_read_(), |
| 44 pipe_write_(), | 45 pipe_write_(), |
| 45 child_port_(MACH_PORT_NULL), | 46 child_port_(MACH_PORT_NULL), |
| 46 checked_in_(false) { | 47 checked_in_(false) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // means that if more than one message is in the queue when kevent() | 207 // means that if more than one message is in the queue when kevent() |
| 207 // returns, no more notifications will be generated. | 208 // returns, no more notifications will be generated. |
| 208 while (!checked_in_) { | 209 while (!checked_in_) { |
| 209 // If a proper message is received from child_port_check_in(), | 210 // If a proper message is received from child_port_check_in(), |
| 210 // this will call HandleChildPortCheckIn(). | 211 // this will call HandleChildPortCheckIn(). |
| 211 mach_msg_return_t mr = | 212 mach_msg_return_t mr = |
| 212 MachMessageServer::Run(&child_port_server, | 213 MachMessageServer::Run(&child_port_server, |
| 213 server_port_set, | 214 server_port_set, |
| 214 MACH_MSG_OPTION_NONE, | 215 MACH_MSG_OPTION_NONE, |
| 215 MachMessageServer::kOneShot, | 216 MachMessageServer::kOneShot, |
| 216 MachMessageServer::kNonblocking, | |
| 217 MachMessageServer::kReceiveLargeIgnore, | 217 MachMessageServer::kReceiveLargeIgnore, |
| 218 MACH_MSG_TIMEOUT_NONE); | 218 kMachMessageTimeoutNonblocking); |
| 219 if (mr == MACH_RCV_TIMED_OUT) { | 219 if (mr == MACH_RCV_TIMED_OUT) { |
| 220 break; | 220 break; |
| 221 } else if (mr != MACH_MSG_SUCCESS) { | 221 } else if (mr != MACH_MSG_SUCCESS) { |
| 222 MACH_LOG(ERROR, mr) << "MachMessageServer::Run"; | 222 MACH_LOG(ERROR, mr) << "MachMessageServer::Run"; |
| 223 return MACH_PORT_NULL; | 223 return MACH_PORT_NULL; |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 break; | 226 break; |
| 227 } | 227 } |
| 228 | 228 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 bootstrap_look_up(bootstrap_port, service_name.c_str(), &server_port); | 340 bootstrap_look_up(bootstrap_port, service_name.c_str(), &server_port); |
| 341 BOOTSTRAP_CHECK(kr == BOOTSTRAP_SUCCESS, kr) << "bootstrap_look_up"; | 341 BOOTSTRAP_CHECK(kr == BOOTSTRAP_SUCCESS, kr) << "bootstrap_look_up"; |
| 342 base::mac::ScopedMachSendRight server_port_owner(server_port); | 342 base::mac::ScopedMachSendRight server_port_owner(server_port); |
| 343 | 343 |
| 344 // Check in with the server. | 344 // Check in with the server. |
| 345 kr = child_port_check_in(server_port, token, port, right_type); | 345 kr = child_port_check_in(server_port, token, port, right_type); |
| 346 MACH_CHECK(kr == KERN_SUCCESS, kr) << "child_port_check_in"; | 346 MACH_CHECK(kr == KERN_SUCCESS, kr) << "child_port_check_in"; |
| 347 } | 347 } |
| 348 | 348 |
| 349 } // namespace crashpad | 349 } // namespace crashpad |
| OLD | NEW |