Tor 0.4.9.0-alpha-dev
Macros | Functions
dispatch_core.c File Reference

Core module for sending and receiving messages. More...

#include "orconfig.h"
#include "lib/dispatch/dispatch.h"
#include "lib/dispatch/dispatch_st.h"
#include "lib/dispatch/dispatch_naming.h"
#include "lib/malloc/malloc.h"
#include "lib/log/util_bug.h"
#include <string.h>

Go to the source code of this file.

Functions

void dispatch_free_msg_ (const dispatch_t *d, msg_t *msg)
 
char * dispatch_fmt_msg_data (const dispatch_t *d, const msg_t *msg)
 
void dispatch_free_ (dispatch_t *d)
 
int dispatch_set_alert_fn (dispatch_t *d, channel_id_t chan, dispatch_alertfn_t fn, void *userdata)
 
int dispatch_send (dispatch_t *d, subsys_id_t sender, channel_id_t channel, message_id_t msg, msg_type_id_t type, msg_aux_data_t auxdata)
 
int dispatch_send_msg (dispatch_t *d, msg_t *m)
 
int dispatch_send_msg_unchecked (dispatch_t *d, msg_t *m)
 
static void dispatcher_run_msg_cbs (const dispatch_t *d, msg_t *m)
 
int dispatch_flush (dispatch_t *d, channel_id_t ch, int max_msgs)
 

Detailed Description

Core module for sending and receiving messages.

Definition in file dispatch_core.c.

Macro Definition Documentation

◆ DISPATCH_PRIVATE

#define DISPATCH_PRIVATE

Definition at line 12 of file dispatch_core.c.

Function Documentation

◆ dispatch_flush()

int dispatch_flush ( dispatch_t d,
channel_id_t  ch,
int  max_msgs 
)

Run up to max_msgs callbacks for messages on the channel ch on the given dispatcher. Return 0 on success or recoverable failure, -1 on unrecoverable error.

Definition at line 241 of file dispatch_core.c.

Referenced by alertfn_immediate().

◆ dispatch_fmt_msg_data()

char * dispatch_fmt_msg_data ( const dispatch_t d,
const msg_t msg 
)

Format the auxiliary data held by msg.

Definition at line 43 of file dispatch_core.c.

Referenced by dispatch_send_msg_unchecked(), and dispatcher_run_msg_cbs().

◆ dispatch_free_()

void dispatch_free_ ( dispatch_t d)

Release all storage held by d.

Definition at line 55 of file dispatch_core.c.

◆ dispatch_free_msg_()

void dispatch_free_msg_ ( const dispatch_t d,
msg_t msg 
)

Use d to drop all storage held for msg.

(We need the dispatcher so we know how to free the auxiliary data.)

Definition at line 30 of file dispatch_core.c.

◆ dispatch_send()

int dispatch_send ( dispatch_t d,
subsys_id_t  sender,
channel_id_t  channel,
message_id_t  msg,
msg_type_id_t  type,
msg_aux_data_t  auxdata 
)

Send a message on the appropriate channel notifying that channel if necessary.

This function takes ownership of the auxiliary data; it can't be static or stack-allocated, and the caller is not allowed to use it afterwards.

This function does not check the various vields of the message object for consistency.

Definition at line 111 of file dispatch_core.c.

◆ dispatch_send_msg()

int dispatch_send_msg ( dispatch_t d,
msg_t m 
)

Definition at line 137 of file dispatch_core.c.

◆ dispatch_send_msg_unchecked()

int dispatch_send_msg_unchecked ( dispatch_t d,
msg_t m 
)

Send a message on the appropriate queue, notifying that queue if necessary.

This function takes ownership of the message object and its auxiliary data; it can't be static or stack-allocated, and the caller isn't allowed to use it afterwards.

This function does not check the various fields of the message object for consistency, and can crash if they are out of range. Only functions that have already constructed the message in a safe way, or checked it for correctness themselves, should call this function.

Definition at line 175 of file dispatch_core.c.

◆ dispatch_set_alert_fn()

int dispatch_set_alert_fn ( dispatch_t d,
channel_id_t  chan,
dispatch_alertfn_t  fn,
void *  userdata 
)

Tell the dispatcher to call fn with userdata whenever chan becomes nonempty. Return 0 on success, -1 on error.

Definition at line 88 of file dispatch_core.c.

◆ dispatcher_run_msg_cbs()

static void dispatcher_run_msg_cbs ( const dispatch_t d,
msg_t m 
)
static

Run all of the callbacks on d associated with m.

Definition at line 208 of file dispatch_core.c.