From 4cca157641d5f91bde51baf437a3179e39d0b601 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 7 Feb 2023 13:31:48 +0100 Subject: Output messages are now processed by the pool of threads. --- data.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'data.c') diff --git a/data.c b/data.c index 3827422..ac429fa 100644 --- a/data.c +++ b/data.c @@ -1373,25 +1373,35 @@ void enqueue_input(snac *snac, xs_dict *msg, xs_dict *req, int retries) } -void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries) +void enqueue_output_raw(const char *keyid, const char *seckey, + xs_dict *msg, xs_str *inbox, int retries) /* enqueues an output message to an inbox */ { - if (xs_startswith(inbox, snac->actor)) { - snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); - return; - } - xs *qmsg = _new_qmsg("output", msg, retries); char *ntid = xs_dict_get(qmsg, "ntid"); - xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid); + xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid); qmsg = xs_dict_append(qmsg, "inbox", inbox); - qmsg = xs_dict_append(qmsg, "keyid", snac->actor); - qmsg = xs_dict_append(qmsg, "seckey", xs_dict_get(snac->key, "secret")); + qmsg = xs_dict_append(qmsg, "keyid", keyid); + qmsg = xs_dict_append(qmsg, "seckey", seckey); qmsg = _enqueue_put(fn, qmsg); - snac_debug(snac, 1, xs_fmt("enqueue_output %s %s %d", inbox, fn, retries)); + srv_debug(1, xs_fmt("enqueue_output %s %s %d", inbox, fn, retries)); +} + + +void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries) +/* enqueues an output message to an inbox */ +{ + if (xs_startswith(inbox, snac->actor)) { + snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); + return; + } + + char *seckey = xs_dict_get(snac->key, "secret"); + + enqueue_output_raw(snac->actor, seckey, msg, inbox, retries); } -- cgit v1.2.3