Use snac_op in instance_failure().
This commit is contained in:
+5
-5
@@ -2594,7 +2594,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
|
||||
}
|
||||
|
||||
/* this instance is alive */
|
||||
instance_failure(actor, 2);
|
||||
instance_failure(actor, OP_DEL);
|
||||
|
||||
/* question votes may not have a type */
|
||||
if (xs_is_null(type))
|
||||
@@ -3029,7 +3029,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
|
||||
const char *who = get_atto(a_msg);
|
||||
|
||||
/* got the admired object: instance is [back] online */
|
||||
instance_failure(object, 2);
|
||||
instance_failure(object, OP_DEL);
|
||||
|
||||
if (who && !is_muted(snac, who)) {
|
||||
/* bring the actor */
|
||||
@@ -3479,7 +3479,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
|
||||
|
||||
/* mark actor and instance as working */
|
||||
actor_failure(actor, OP_DEL);
|
||||
instance_failure(actor, 2);
|
||||
instance_failure(actor, OP_DEL);
|
||||
}
|
||||
else {
|
||||
if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) {
|
||||
@@ -3604,7 +3604,7 @@ void process_queue_item(xs_dict *q_item)
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance_failure(inbox, 0)) {
|
||||
if (instance_failure(inbox, OP_CHECK)) {
|
||||
srv_debug(1, xs_fmt("output message error: too many failures for instance %s", inbox));
|
||||
return;
|
||||
}
|
||||
@@ -3621,7 +3621,7 @@ void process_queue_item(xs_dict *q_item)
|
||||
status = send_to_inbox_raw(keyid, seckey, inbox, msg, &payload, &p_size, timeout);
|
||||
|
||||
/* register or clear a value for this instance */
|
||||
instance_failure(inbox, valid_status(status) ? 2 : 1);
|
||||
instance_failure(inbox, valid_status(status) ? OP_DEL : OP_ADD);
|
||||
|
||||
if (payload) {
|
||||
if (p_size > 1024) {
|
||||
|
||||
@@ -3275,7 +3275,7 @@ int actor_failure(const char *actor, snac_op op)
|
||||
}
|
||||
|
||||
|
||||
int instance_failure(const char *url, int op)
|
||||
int instance_failure(const char *url, snac_op op)
|
||||
/* do some checks and accounting on instance failures */
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -3290,7 +3290,7 @@ int instance_failure(const char *url, int op)
|
||||
xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5);
|
||||
|
||||
switch (op) {
|
||||
case 0: /** check **/
|
||||
case OP_CHECK: /** check **/
|
||||
if ((mt = mtime(fn)) != 0.0) {
|
||||
/* grace time */
|
||||
double seconds_failing = xs_number_get(xs_dict_get_def(srv_config, "max_failing_days", "15"))
|
||||
@@ -3302,7 +3302,7 @@ int instance_failure(const char *url, int op)
|
||||
|
||||
break;
|
||||
|
||||
case 1: /** register a failure **/
|
||||
case OP_ADD: /** register a failure **/
|
||||
if (mtime(fn) == 0.0) {
|
||||
FILE *f;
|
||||
|
||||
@@ -3315,11 +3315,14 @@ int instance_failure(const char *url, int op)
|
||||
|
||||
break;
|
||||
|
||||
case 2: /** clear a failure **/
|
||||
case OP_DEL: /** clear a failure **/
|
||||
/* called whenever a message comes from this instance */
|
||||
unlink(fn);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -282,7 +282,7 @@ void rss_to_timeline(snac *user, const char *url)
|
||||
continue;
|
||||
|
||||
/* the instance is [back] online */
|
||||
instance_failure(id, 2);
|
||||
instance_failure(id, OP_DEL);
|
||||
|
||||
if (timeline_here(user, id)) {
|
||||
snac_debug(user, 1, xs_fmt("RSS entry already in timeline (id) %s", id));
|
||||
|
||||
@@ -309,7 +309,7 @@ xs_list *content_search(snac *user, const char *regex,
|
||||
int priv, int skip, int show, int max_secs, int *timeout);
|
||||
|
||||
int actor_failure(const char *actor, snac_op op);
|
||||
int instance_failure(const char *url, int op);
|
||||
int instance_failure(const char *url, snac_op op);
|
||||
|
||||
int grave(const char *objid, int op);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user