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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 //! interpret and validate it, and if the message is valid, returns the | 211 //! interpret and validate it, and if the message is valid, returns the |
212 //! port right extracted from the message. If the message is not valid, | 212 //! port right extracted from the message. If the message is not valid, |
213 //! this method will continue waiting for a valid message. Valid messages | 213 //! this method will continue waiting for a valid message. Valid messages |
214 //! are properly formatted and have the correct token. The right carried in | 214 //! are properly formatted and have the correct token. The right carried in |
215 //! a valid message will be returned. If a message is not valid, this | 215 //! a valid message will be returned. If a message is not valid, this |
216 //! method will continue waiting for pipe EOF or a valid message. | 216 //! method will continue waiting for pipe EOF or a valid message. |
217 //! - When notified of pipe EOF, returns `MACH_PORT_NULL`. | 217 //! - When notified of pipe EOF, returns `MACH_PORT_NULL`. |
218 //! - Regardless of return value, destroys the server’s receive right and | 218 //! - Regardless of return value, destroys the server’s receive right and |
219 //! closes the pipe. | 219 //! closes the pipe. |
220 //! | 220 //! |
| 221 //! \param[in] server_write_fd The write side of the pipe shared with the |
| 222 //! client process. This function takes ownership of this file descriptor, |
| 223 //! and will close it prior to returning. |
221 //! \param[in] port_right_type The port right type expected to be received | 224 //! \param[in] port_right_type The port right type expected to be received |
222 //! from the client. If the port right received from the client does not | 225 //! from the client. If the port right received from the client does not |
223 //! match the expected type, the received port right will be destroyed, | 226 //! match the expected type, the received port right will be destroyed, |
224 //! and `MACH_PORT_NULL` will be returned. | 227 //! and `MACH_PORT_NULL` will be returned. |
225 //! | 228 //! |
226 //! \return On success, the port right provided by the client. The caller | 229 //! \return On success, the port right provided by the client. The caller |
227 //! takes ownership of this right. On failure, `MACH_PORT_NULL`, | 230 //! takes ownership of this right. On failure, `MACH_PORT_NULL`, |
228 //! indicating that the client did not check in properly before | 231 //! indicating that the client did not check in properly before |
229 //! terminating, where termination is detected by detecting that the read | 232 //! terminating, where termination is detected by detecting that the read |
230 //! side of the shared pipe has closed. On failure, a message indicating | 233 //! side of the shared pipe has closed. On failure, a message indicating |
(...skipping 15 matching lines...) Expand all Loading... |
246 //! - Obtains a send right to the server by calling `bootstrap_look_up()`. | 249 //! - Obtains a send right to the server by calling `bootstrap_look_up()`. |
247 //! - Sends a check-in message to the server by calling | 250 //! - Sends a check-in message to the server by calling |
248 //! `child_port_check_in()`, providing the token and the user-supplied port | 251 //! `child_port_check_in()`, providing the token and the user-supplied port |
249 //! right. | 252 //! right. |
250 //! - Deallocates the send right to the server, and closes the pipe. | 253 //! - Deallocates the send right to the server, and closes the pipe. |
251 //! | 254 //! |
252 //! There is no return value because `child_port_check_in()` is a MIG | 255 //! There is no return value because `child_port_check_in()` is a MIG |
253 //! `simpleroutine`, and the server does not send a reply. This allows | 256 //! `simpleroutine`, and the server does not send a reply. This allows |
254 //! check-in to occur without blocking to wait for a reply. | 257 //! check-in to occur without blocking to wait for a reply. |
255 //! | 258 //! |
256 //! \param[in] pipe_read The “read” side of the pipe shared with the server | 259 //! \param[in] client_read_fd The “read” side of the pipe shared with the |
257 //! process. This function takes ownership of this file descriptor, and | 260 //! server process. This function takes ownership of this file descriptor, |
258 //! will close it prior to returning. | 261 //! and will close it prior to returning. |
259 //! \param[in] port The port right that will be passed to the server by | 262 //! \param[in] port The port right that will be passed to the server by |
260 //! `child_port_check_in()`. | 263 //! `child_port_check_in()`. |
261 //! \param[in] right_type The right type to furnish the server with. If \a | 264 //! \param[in] right_type The right type to furnish the server with. If \a |
262 //! port is a send right, this can be `MACH_MSG_TYPE_COPY_SEND` or | 265 //! port is a send right, this can be `MACH_MSG_TYPE_COPY_SEND` or |
263 //! `MACH_MSG_TYPE_MOVE_SEND`. If \a port is a send-once right, this can | 266 //! `MACH_MSG_TYPE_MOVE_SEND`. If \a port is a send-once right, this can |
264 //! be `MACH_MSG_TYPE_MOVE_SEND_ONCE`. If \a port is a receive right, this | 267 //! be `MACH_MSG_TYPE_MOVE_SEND_ONCE`. If \a port is a receive right, this |
265 //! can be `MACH_MSG_TYPE_MAKE_SEND`, `MACH_MSG_TYPE_MAKE_SEND_ONCE`, or | 268 //! can be `MACH_MSG_TYPE_MAKE_SEND`, `MACH_MSG_TYPE_MAKE_SEND_ONCE`, or |
266 //! `MACH_MSG_TYPE_MOVE_RECEIVE`. | 269 //! `MACH_MSG_TYPE_MOVE_RECEIVE`. |
267 //! | 270 //! |
268 //! \return `true` on success, `false` on failure with a message logged. On | 271 //! \return `true` on success, `false` on failure with a message logged. On |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 base::ScopedFD server_write_fd_; | 321 base::ScopedFD server_write_fd_; |
319 | 322 |
320 friend class test::ChildPortHandshakeTest; | 323 friend class test::ChildPortHandshakeTest; |
321 | 324 |
322 DISALLOW_COPY_AND_ASSIGN(ChildPortHandshake); | 325 DISALLOW_COPY_AND_ASSIGN(ChildPortHandshake); |
323 }; | 326 }; |
324 | 327 |
325 } // namespace crashpad | 328 } // namespace crashpad |
326 | 329 |
327 #endif // CRASHPAD_UTIL_MACH_CHILD_PORT_HANDSHAKE_H_ | 330 #endif // CRASHPAD_UTIL_MACH_CHILD_PORT_HANDSHAKE_H_ |
OLD | NEW |