| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 info_->remote_port.reset(); | 208 info_->remote_port.reset(); |
| 209 info_->local_port.reset(); | 209 info_->local_port.reset(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void MachMultiprocess::MultiprocessChild() { | 212 void MachMultiprocess::MultiprocessChild() { |
| 213 ScopedForbidReturn forbid_return;; | 213 ScopedForbidReturn forbid_return;; |
| 214 | 214 |
| 215 // local_port is not valid in the forked child process. | 215 // local_port is not valid in the forked child process. |
| 216 ignore_result(info_->local_port.release()); | 216 ignore_result(info_->local_port.release()); |
| 217 | 217 |
| 218 mach_port_t local_port; | 218 info_->local_port.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
| 219 kern_return_t kr = mach_port_allocate( | 219 ASSERT_NE(kMachPortNull, info_->local_port); |
| 220 mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &local_port); | |
| 221 ASSERT_EQ(KERN_SUCCESS, kr) << MachErrorMessage(kr, "mach_port_allocate"); | |
| 222 info_->local_port.reset(local_port); | |
| 223 | 220 |
| 224 // The remote port can be obtained from the bootstrap server. | 221 // The remote port can be obtained from the bootstrap server. |
| 225 mach_port_t remote_port; | 222 mach_port_t remote_port; |
| 226 kr = bootstrap_look_up( | 223 kern_return_t kr = bootstrap_look_up( |
| 227 bootstrap_port, info_->service_name.c_str(), &remote_port); | 224 bootstrap_port, info_->service_name.c_str(), &remote_port); |
| 228 ASSERT_EQ(BOOTSTRAP_SUCCESS, kr) | 225 ASSERT_EQ(BOOTSTRAP_SUCCESS, kr) |
| 229 << BootstrapErrorMessage(kr, "bootstrap_look_up"); | 226 << BootstrapErrorMessage(kr, "bootstrap_look_up"); |
| 230 info_->remote_port.reset(remote_port); | 227 info_->remote_port.reset(remote_port); |
| 231 | 228 |
| 232 // The “hello” message will provide the parent with its remote port, a send | 229 // The “hello” message will provide the parent with its remote port, a send |
| 233 // right to the child task’s local port receive right. It will also carry a | 230 // right to the child task’s local port receive right. It will also carry a |
| 234 // send right to the child task’s task port. | 231 // send right to the child task’s task port. |
| 235 SendHelloMessage message = {}; | 232 SendHelloMessage message = {}; |
| 236 message.header.msgh_bits = | 233 message.header.msgh_bits = |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (testing::Test::HasFailure()) { | 267 if (testing::Test::HasFailure()) { |
| 271 // Trigger the ScopedForbidReturn destructor. | 268 // Trigger the ScopedForbidReturn destructor. |
| 272 return; | 269 return; |
| 273 } | 270 } |
| 274 | 271 |
| 275 forbid_return.Disarm(); | 272 forbid_return.Disarm(); |
| 276 } | 273 } |
| 277 | 274 |
| 278 } // namespace test | 275 } // namespace test |
| 279 } // namespace crashpad | 276 } // namespace crashpad |
| OLD | NEW |