Crashpad
|
Runs a Mach message server to handle a Mach RPC request for MIG servers. More...
#include "util/mach/mach_message_server.h"
Classes | |
class | Interface |
A Mach RPC callback interface, called by Run(). More... | |
Public Types | |
enum | Persistent |
Informs Run() whether to handle a single request-reply transaction or to run in a loop. More... | |
enum | ReceiveLarge |
Determines how to handle the reception of messages larger than the size of the buffer allocated to store them. More... | |
Static Public Member Functions | |
static mach_msg_return_t | Run (Interface *interface, mach_port_t receive_port, mach_msg_options_t options, Persistent persistent, ReceiveLarge receive_large, mach_msg_timeout_t timeout_ms) |
Runs a Mach message server to handle a Mach RPC request for MIG servers. More... | |
Runs a Mach message server to handle a Mach RPC request for MIG servers.
The principal entry point to this interface is the static Run() method.
Informs Run() whether to handle a single request-reply transaction or to run in a loop.
Enumerator | |
---|---|
kOneShot | Handle a single request-reply transaction and then return. |
kPersistent | Run in a loop, potentially handling multiple request-reply transactions. |
Determines how to handle the reception of messages larger than the size of the buffer allocated to store them.
Enumerator | |
---|---|
kReceiveLargeError | Return This mimics the default behavior of `mach_msg_server()` when `options` does not contain `MACH_RCV_LARGE`. |
kReceiveLargeIgnore | Ignore large messages, and attempt to receive the next queued message upon encountering one. When a large message is encountered, a warning will be logged.
|
kReceiveLargeResize | Allocate an appropriately-sized buffer upon encountering a large message. The buffer will be used to receive the message. This. This mimics the behavior of |
|
static |
Runs a Mach message server to handle a Mach RPC request for MIG servers.
This function listens for a request message and passes it to a callback interface. A reponse is collected from that interface, and is sent back as a reply.
This function is similar to mach_msg_server()
and mach_msg_server_once()
.
[in] | interface | The MachMessageServerInterface that is responsible for handling the message. Interface::MachMessageServerRequestSize() is used as the receive size for the request message, and Interface::MachMessageServerReplySize() is used as the maximum size of the reply message. If options contains MACH_RCV_LARGE , this function will retry a receive operation that returns MACH_RCV_TOO_LARGE with an appropriately-sized buffer. MachMessageServerInterface::MachMessageServerFunction() is called to handle the request and populate the reply. |
[in] | receive_port | The port on which to receive the request message. |
[in] | options | Options suitable for mach_msg. For the defaults, use MACH_MSG_OPTION_NONE . MACH_RCV_LARGE when specified here is ignored. Set receive_large to kReceiveLargeResize instead. |
[in] | persistent | Chooses between one-shot and persistent operation. |
[in] | receive_large | Determines the behavior upon encountering a message larger than the receive buffer’s size. |
[in] | timeout_ms | The maximum duration that this entire function will run, in milliseconds. This may be kMachMessageTimeoutNonblocking or kMachMessageTimeoutWaitIndefinitely. When persistent is kPersistent, the timeout applies to the overall duration of this function, not to any individual mach_msg() call. |
MACH_MSG_SUCCESS
(when persistent is kOneShot) or MACH_RCV_TIMED_OUT
(when persistent is kOneShot and timeout_ms is not kMachMessageTimeoutWaitIndefinitely). This function has no successful return value when persistent is kPersistent and timeout_ms is kMachMessageTimeoutWaitIndefinitely. On failure, returns a value identifying the nature of the error. A request received with a reply port that is (or becomes) a dead name before the reply is sent will result in MACH_SEND_INVALID_DEST
as a return value, which may or may not be considered an error from the caller’s perspective.