| 85 | } |
| 86 | |
| 87 | static struct command_result *clean_finished(struct clean_info *cinfo) |
| 88 | { |
| 89 | for (enum subsystem i = 0; i < NUM_SUBSYSTEM; i++) { |
| 90 | if (!cinfo->num_cleaned[i]) |
| 91 | continue; |
| 92 | |
| 93 | plugin_log(plugin, LOG_DBG, "cleaned %"PRIu64" from %s", |
| 94 | cinfo->num_cleaned[i], subsystem_to_str(i)); |
| 95 | total_cleaned[i] += cinfo->num_cleaned[i]; |
| 96 | jsonrpc_set_datastore_string(plugin, cinfo->cmd, |
| 97 | datastore_path(tmpctx, i, "num"), |
| 98 | tal_fmt(tmpctx, "%"PRIu64, total_cleaned[i]), |
| 99 | "create-or-replace", NULL, NULL, NULL); |
| 100 | |
| 101 | } |
| 102 | |
| 103 | /* autoclean-once? */ |
| 104 | if (cinfo->cmd) { |
| 105 | struct json_stream *response = jsonrpc_stream_success(cinfo->cmd); |
| 106 | |
| 107 | json_object_start(response, "autoclean"); |
| 108 | for (enum subsystem i = 0; i < NUM_SUBSYSTEM; i++) { |
| 109 | if (cinfo->subsystem_age[i] == 0) |
| 110 | continue; |
| 111 | json_object_start(response, subsystem_to_str(i)); |
| 112 | json_add_u64(response, "cleaned", cinfo->num_cleaned[i]); |
| 113 | json_add_u64(response, "uncleaned", cinfo->num_uncleaned); |
| 114 | json_object_end(response); |
| 115 | } |
| 116 | json_object_end(response); |
| 117 | return command_finished(cinfo->cmd, response); |
| 118 | } else { /* timer */ |
| 119 | plugin_log(plugin, LOG_DBG, "setting next timer"); |
| 120 | cleantimer = plugin_timer(plugin, time_from_sec(cycle_seconds), |
| 121 | do_clean_timer, NULL); |
| 122 | return timer_complete(plugin); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | static struct command_result *clean_finished_one(struct clean_info *cinfo) |
| 127 | { |
no test coverage detected