diff options
| -rw-r--r-- | data.c | 27 | ||||
| -rw-r--r-- | snac.h | 1 |
2 files changed, 19 insertions, 9 deletions
| @@ -3042,18 +3042,13 @@ xs_list *content_search(snac *user, const char *regex, | |||
| 3042 | } | 3042 | } |
| 3043 | 3043 | ||
| 3044 | 3044 | ||
| 3045 | int instance_failure(const char *url, int op) | 3045 | int actor_failure(const char *id, int op) |
| 3046 | /* do some checks and accounting on instance failures */ | 3046 | /* actor failure maintenance */ |
| 3047 | { | 3047 | { |
| 3048 | int ret = 0; | 3048 | int ret = 0; |
| 3049 | xs *l = xs_split(url, "/"); | ||
| 3050 | const char *hostname = xs_list_get(l, 2); | ||
| 3051 | double mt; | 3049 | double mt; |
| 3052 | 3050 | ||
| 3053 | if (!xs_is_string(hostname)) | 3051 | xs *md5 = xs_md5_hex(id, strlen(id)); |
| 3054 | return 0; | ||
| 3055 | |||
| 3056 | xs *md5 = xs_md5_hex(hostname, strlen(hostname)); | ||
| 3057 | xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5); | 3052 | xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5); |
| 3058 | 3053 | ||
| 3059 | switch (op) { | 3054 | switch (op) { |
| @@ -3075,7 +3070,7 @@ int instance_failure(const char *url, int op) | |||
| 3075 | 3070 | ||
| 3076 | /* only create once, as the date will be used */ | 3071 | /* only create once, as the date will be used */ |
| 3077 | if ((f = fopen(fn, "w")) != NULL) { | 3072 | if ((f = fopen(fn, "w")) != NULL) { |
| 3078 | fprintf(f, "%s\n", hostname); | 3073 | fprintf(f, "%s\n", id); |
| 3079 | fclose(f); | 3074 | fclose(f); |
| 3080 | } | 3075 | } |
| 3081 | } | 3076 | } |
| @@ -3093,6 +3088,20 @@ int instance_failure(const char *url, int op) | |||
| 3093 | } | 3088 | } |
| 3094 | 3089 | ||
| 3095 | 3090 | ||
| 3091 | int instance_failure(const char *url, int op) | ||
| 3092 | /* instance failure maintenance */ | ||
| 3093 | { | ||
| 3094 | /* extract just the host name */ | ||
| 3095 | xs *l = xs_split(url, "/"); | ||
| 3096 | const char *hostname = xs_list_get(l, 2); | ||
| 3097 | |||
| 3098 | if (!xs_is_string(hostname)) | ||
| 3099 | return 0; | ||
| 3100 | |||
| 3101 | return actor_failure(hostname, op); | ||
| 3102 | } | ||
| 3103 | |||
| 3104 | |||
| 3096 | /** notifications **/ | 3105 | /** notifications **/ |
| 3097 | 3106 | ||
| 3098 | xs_str *notify_check_time(snac *snac, int reset) | 3107 | xs_str *notify_check_time(snac *snac, int reset) |
| @@ -278,6 +278,7 @@ int content_match(const char *file, const xs_dict *msg); | |||
| 278 | xs_list *content_search(snac *user, const char *regex, | 278 | xs_list *content_search(snac *user, const char *regex, |
| 279 | int priv, int skip, int show, int max_secs, int *timeout); | 279 | int priv, int skip, int show, int max_secs, int *timeout); |
| 280 | 280 | ||
| 281 | int actor_failure(const char *id, int op); | ||
| 281 | int instance_failure(const char *url, int op); | 282 | int instance_failure(const char *url, int op); |
| 282 | 283 | ||
| 283 | void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); | 284 | void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); |