Crashpad
Classes | Public Types | Static Public Member Functions | List of all members
crashpad::MachMessageServer Class Reference

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...
 

Detailed Description

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.

Member Enumeration Documentation

◆ Persistent

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.

◆ ReceiveLarge

Determines how to handle the reception of messages larger than the size of the buffer allocated to store them.

Enumerator
kReceiveLargeError 

Return MACH_RCV_TOO_LARGE upon receipt of a large message.

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.

mach_msg() will be called to receive the next message after a large one even when accompanied by a Persistent value of kOneShot.

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 mach_msg_server() when options contains MACH_RCV_LARGE.

Member Function Documentation

◆ Run()

mach_msg_return_t crashpad::MachMessageServer::Run ( Interface interface,
mach_port_t  receive_port,
mach_msg_options_t  options,
Persistent  persistent,
ReceiveLarge  receive_large,
mach_msg_timeout_t  timeout_ms 
)
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().

Parameters
[in]interfaceThe 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_portThe port on which to receive the request message.
[in]optionsOptions 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]persistentChooses between one-shot and persistent operation.
[in]receive_largeDetermines the behavior upon encountering a message larger than the receive buffer’s size.
[in]timeout_msThe 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.
Returns
On success, 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.

The documentation for this class was generated from the following files: