diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 39 |
1 files changed, 39 insertions, 0 deletions
| @@ -3046,6 +3046,45 @@ xs_list *content_search(snac *user, const char *regex, | |||
| 3046 | } | 3046 | } |
| 3047 | 3047 | ||
| 3048 | 3048 | ||
| 3049 | int actor_failure(const char *actor, int op) | ||
| 3050 | /* actor failure maintenance */ | ||
| 3051 | { | ||
| 3052 | int ret = 0; | ||
| 3053 | |||
| 3054 | xs *md5 = xs_md5_hex(actor, strlen(actor)); | ||
| 3055 | xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5); | ||
| 3056 | |||
| 3057 | switch (op) { | ||
| 3058 | case 0: /** check **/ | ||
| 3059 | if (mtime(fn)) | ||
| 3060 | ret = -1; | ||
| 3061 | |||
| 3062 | break; | ||
| 3063 | |||
| 3064 | case 1: /** register a failure **/ | ||
| 3065 | if (mtime(fn) == 0.0) { | ||
| 3066 | FILE *f; | ||
| 3067 | |||
| 3068 | /* only create once, as the date will be used */ | ||
| 3069 | if ((f = fopen(fn, "w")) != NULL) { | ||
| 3070 | fprintf(f, "%s\n", actor); | ||
| 3071 | fclose(f); | ||
| 3072 | } | ||
| 3073 | } | ||
| 3074 | |||
| 3075 | break; | ||
| 3076 | |||
| 3077 | case 2: /** clear a failure **/ | ||
| 3078 | /* called whenever a message comes from this instance */ | ||
| 3079 | unlink(fn); | ||
| 3080 | |||
| 3081 | break; | ||
| 3082 | } | ||
| 3083 | |||
| 3084 | return ret; | ||
| 3085 | } | ||
| 3086 | |||
| 3087 | |||
| 3049 | int instance_failure(const char *url, int op) | 3088 | int instance_failure(const char *url, int op) |
| 3050 | /* do some checks and accounting on instance failures */ | 3089 | /* do some checks and accounting on instance failures */ |
| 3051 | { | 3090 | { |