commit 71a83e6
default
·
2026-08-26 05:59:23 +0000 UTC
parent 6ae12b0
Use snac_op in actor_failure().
4 files changed,
+22,
-11
+5,
-5
1@@ -3054,7 +3054,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
2 followed_hashtag_distribute(a_msg);
3
4 /* actor is [back] alive */
5- actor_failure(who, 2);
6+ actor_failure(who, OP_DEL);
7
8 do_notify = 1;
9 }
10@@ -3461,7 +3461,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
11 const char *actor = xs_dict_get(q_item, "actor");
12 double mtime = object_mtime(actor);
13
14- if (actor_failure(actor, 0) == -1) {
15+ if (actor_failure(actor, OP_CHECK) == -1) {
16 /* actor is broken beyond repair */
17 snac_debug(user, 1, xs_fmt("actor_refresh skipped broken actor %s", actor));
18 }
19@@ -3478,16 +3478,16 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
20 actor_add(actor, actor_o);
21
22 /* mark actor and instance as working */
23- actor_failure(actor, 2);
24+ actor_failure(actor, OP_DEL);
25 instance_failure(actor, 2);
26 }
27 else {
28 if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) {
29- actor_failure(actor, 1);
30+ actor_failure(actor, OP_ADD);
31 snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status));
32 }
33 else {
34- actor_failure(actor, 2);
35+ actor_failure(actor, OP_DEL);
36 object_touch(actor);
37 }
38 }
M
data.c
+7,
-4
1@@ -3233,7 +3233,7 @@ xs_list *content_search(snac *user, const char *regex,
2 }
3
4
5-int actor_failure(const char *actor, int op)
6+int actor_failure(const char *actor, snac_op op)
7 /* actor failure maintenance */
8 {
9 int ret = 0;
10@@ -3242,13 +3242,13 @@ int actor_failure(const char *actor, int op)
11 xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5);
12
13 switch (op) {
14- case 0: /** check **/
15+ case OP_CHECK: /** check **/
16 if (mtime(fn))
17 ret = -1;
18
19 break;
20
21- case 1: /** register a failure **/
22+ case OP_ADD: /** register a failure **/
23 if (mtime(fn) == 0.0) {
24 FILE *f;
25
26@@ -3261,11 +3261,14 @@ int actor_failure(const char *actor, int op)
27
28 break;
29
30- case 2: /** clear a failure **/
31+ case OP_DEL: /** clear a failure **/
32 /* called whenever a message comes from this instance */
33 unlink(fn);
34
35 break;
36+
37+ default:
38+ break;
39 }
40
41 return ret;
M
html.c
+1,
-1
1@@ -362,7 +362,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
2 xs_html_raw("💔")));
3 }
4
5- if (actor_failure(actor_id, 0) == -1) {
6+ if (actor_failure(actor_id, OP_CHECK) == -1) {
7 xs_html_add(actor_icon,
8 xs_html_text(" "),
9 xs_html_tag("span",
M
snac.h
+9,
-1
1@@ -79,6 +79,14 @@ typedef struct {
2 enum { THST_STOP, THST_WAIT, THST_IN, THST_QUEUE } th_state[MAX_THREADS];
3 } srv_state;
4
5+typedef enum {
6+ OP_CHECK = 0,
7+ OP_ADD = 1,
8+ OP_DEL = 2,
9+ OP_LIST = 3,
10+ OP_FIND = 4
11+} snac_op;
12+
13 extern srv_state *p_state;
14
15 enum {
16@@ -300,7 +308,7 @@ int content_match(const char *file, const xs_dict *msg);
17 xs_list *content_search(snac *user, const char *regex,
18 int priv, int skip, int show, int max_secs, int *timeout);
19
20-int actor_failure(const char *actor, int op);
21+int actor_failure(const char *actor, snac_op op);
22 int instance_failure(const char *url, int op);
23
24 int grave(const char *objid, int op);