12 #define PUBSUB_PRIVATE
48 pubsub_type_cfg_t *, item,
tor_free(item));
49 smartlist_free(cfg->items);
50 smartlist_free(cfg->type_items);
58 dispatch_naming_init();
93 ++builder->n_connectors;
97 con->builder = builder;
98 con->subsys_id = subsys;
113 --con->builder->n_connectors;
126 channel_id_t channel,
133 pubsub_cfg_t *cfg = tor_malloc_zero(
sizeof(*cfg));
135 memset(out, 0,
sizeof(*out));
136 cfg->is_publish =
true;
138 out->
msg_template.sender = cfg->subsys = con->subsys_id;
144 cfg->added_by_file = file;
145 cfg->added_by_line = line;
150 cfg->pub_binding = out;
161 ++con->builder->n_errors;
173 channel_id_t channel,
180 pubsub_cfg_t *cfg = tor_malloc_zero(
sizeof(*cfg));
182 cfg->is_publish =
false;
183 cfg->subsys = con->subsys_id;
184 cfg->channel = channel;
188 cfg->added_by_file = file;
189 cfg->added_by_line = line;
191 cfg->recv_fn = recv_fn;
200 if (
dcfg_add_recv(con->builder->cfg, msg, cfg->subsys, recv_fn) < 0)
206 ++con->builder->n_errors;
222 pubsub_type_cfg_t *cfg = tor_malloc_zero(
sizeof(*cfg));
224 memcpy(&cfg->fns, fns,
sizeof(*fns));
225 cfg->subsys = con->subsys_id;
226 cfg->added_by_file = file;
227 cfg->added_by_line = line;
236 ++con->builder->n_errors;
249 if (cfg->pub_binding) {
252 cfg->pub_binding->dispatch_ptr = d;
254 } SMARTLIST_FOREACH_END(cfg);
266 if (cfg->pub_binding) {
267 cfg->pub_binding->dispatch_ptr = NULL;
269 } SMARTLIST_FOREACH_END(cfg);
282 tor_assert_nonfatal(builder->n_connectors == 0);
287 if (builder->n_errors) {
288 log_warn(
LD_GENERAL,
"At least one error occurred previously when "
289 "configuring the dispatcher.");
300 *items_out = builder->items;
301 builder->items = NULL;
Low-level APIs for message-passing system.
struct dispatch_t dispatch_t
int dcfg_msg_set_chan(dispatch_cfg_t *cfg, message_id_t msg, channel_id_t chan)
int dcfg_type_set_fns(dispatch_cfg_t *cfg, msg_type_id_t type, const dispatch_typefns_t *fns)
dispatch_cfg_t * dcfg_new(void)
int dcfg_msg_set_type(dispatch_cfg_t *cfg, message_id_t msg, msg_type_id_t type)
int dcfg_add_recv(dispatch_cfg_t *cfg, message_id_t msg, subsys_id_t sys, recv_fn_t fn)
Header for distpach_cfg.c.
Header for dispatch_naming.c.
dispatch_t * dispatch_new(const dispatch_cfg_t *cfg)
Headers for util_malloc.c.
Types used for messages in the dispatcher code.
void(* recv_fn_t)(const msg_t *m)
Declaration of pub_binding_t.
pubsub_connector_t * pubsub_connector_for_subsystem(pubsub_builder_t *builder, subsys_id_t subsys)
dispatch_t * pubsub_builder_finalize(pubsub_builder_t *builder, pubsub_items_t **items_out)
int pubsub_add_pub_(pubsub_connector_t *con, pub_binding_t *out, channel_id_t channel, message_id_t msg, msg_type_id_t type, unsigned flags, const char *file, unsigned line)
void pubsub_connector_free_(pubsub_connector_t *con)
void pubsub_items_free_(pubsub_items_t *cfg)
void pubsub_builder_free_(pubsub_builder_t *pb)
static pubsub_items_t * pubsub_items_new(void)
int pubsub_connector_register_type_(pubsub_connector_t *con, msg_type_id_t type, dispatch_typefns_t *fns, const char *file, unsigned line)
pubsub_builder_t * pubsub_builder_new(void)
void pubsub_items_clear_bindings(pubsub_items_t *items)
static void pubsub_items_install_bindings(pubsub_items_t *items, dispatch_t *d)
int pubsub_add_sub_(pubsub_connector_t *con, recv_fn_t recv_fn, channel_id_t channel, message_id_t msg, msg_type_id_t type, unsigned flags, const char *file, unsigned line)
Header used for constructing the OO publish-subscribe facility.
#define pubsub_builder_free(db)
int pubsub_builder_check(pubsub_builder_t *)
struct pubsub_items_t pubsub_items_t
struct pubsub_builder_t pubsub_builder_t
#define pubsub_items_free(cfg)
private structures used for configuring dispatchers and messages.
Header for functions that add relationships to a pubsub builder.
struct pubsub_connector_t pubsub_connector_t
Flags that can be set on publish/subscribe messages.
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
Macros to manage assertions, fatal and non-fatal.