commit 48aba53

default  ·  2026-08-26 06:02:41 +0000 UTC
parent 71a83e6
Use snac_op in instance_failure().
4 files changed,  +14, -11
M data.c
M rss.c
M snac.h
+5, -5
 1@@ -2594,7 +2594,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
 2     }
 3 
 4     /* this instance is alive */
 5-    instance_failure(actor, 2);
 6+    instance_failure(actor, OP_DEL);
 7 
 8     /* question votes may not have a type */
 9     if (xs_is_null(type))
10@@ -3029,7 +3029,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
11                 const char *who = get_atto(a_msg);
12 
13                 /* got the admired object: instance is [back] online */
14-                instance_failure(object, 2);
15+                instance_failure(object, OP_DEL);
16 
17                 if (who && !is_muted(snac, who)) {
18                     /* bring the actor */
19@@ -3479,7 +3479,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
20 
21                 /* mark actor and instance as working */
22                 actor_failure(actor, OP_DEL);
23-                instance_failure(actor, 2);
24+                instance_failure(actor, OP_DEL);
25             }
26             else {
27                 if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) {
28@@ -3604,7 +3604,7 @@ void process_queue_item(xs_dict *q_item)
29             return;
30         }
31 
32-        if (instance_failure(inbox, 0)) {
33+        if (instance_failure(inbox, OP_CHECK)) {
34             srv_debug(1, xs_fmt("output message error: too many failures for instance %s", inbox));
35             return;
36         }
37@@ -3621,7 +3621,7 @@ void process_queue_item(xs_dict *q_item)
38         status = send_to_inbox_raw(keyid, seckey, inbox, msg, &payload, &p_size, timeout);
39 
40         /* register or clear a value for this instance */
41-        instance_failure(inbox, valid_status(status) ? 2 : 1);
42+        instance_failure(inbox, valid_status(status) ? OP_DEL : OP_ADD);
43 
44         if (payload) {
45             if (p_size > 1024) {
M data.c
+7, -4
 1@@ -3275,7 +3275,7 @@ int actor_failure(const char *actor, snac_op op)
 2 }
 3 
 4 
 5-int instance_failure(const char *url, int op)
 6+int instance_failure(const char *url, snac_op op)
 7 /* do some checks and accounting on instance failures */
 8 {
 9     int ret = 0;
10@@ -3290,7 +3290,7 @@ int instance_failure(const char *url, 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 ((mt = mtime(fn)) != 0.0) {
17             /* grace time */
18             double seconds_failing = xs_number_get(xs_dict_get_def(srv_config, "max_failing_days", "15"))
19@@ -3302,7 +3302,7 @@ int instance_failure(const char *url, int op)
20 
21         break;
22 
23-    case 1: /** register a failure **/
24+    case OP_ADD: /** register a failure **/
25         if (mtime(fn) == 0.0) {
26             FILE *f;
27 
28@@ -3315,11 +3315,14 @@ int instance_failure(const char *url, int op)
29 
30         break;
31 
32-    case 2: /** clear a failure **/
33+    case OP_DEL: /** clear a failure **/
34         /* called whenever a message comes from this instance */
35         unlink(fn);
36 
37         break;
38+
39+    default:
40+        break;
41     }
42 
43     return ret;
M rss.c
+1, -1
1@@ -282,7 +282,7 @@ void rss_to_timeline(snac *user, const char *url)
2                 continue;
3 
4             /* the instance is [back] online */
5-            instance_failure(id, 2);
6+            instance_failure(id, OP_DEL);
7 
8             if (timeline_here(user, id)) {
9                 snac_debug(user, 1, xs_fmt("RSS entry already in timeline (id) %s", id));
M snac.h
+1, -1
1@@ -309,7 +309,7 @@ xs_list *content_search(snac *user, const char *regex,
2             int priv, int skip, int show, int max_secs, int *timeout);
3 
4 int actor_failure(const char *actor, snac_op op);
5-int instance_failure(const char *url, int op);
6+int instance_failure(const char *url, snac_op op);
7 
8 int grave(const char *objid, int op);
9