From a11f8666a3e8e5e7aaedce9a98cfc949fd738b95 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Fri, 30 Oct 2020 16:51:05 +0100 Subject: [PATCH] main: allow silent reporting --- kernel/sy_old/mars_main.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/kernel/sy_old/mars_main.c b/kernel/sy_old/mars_main.c index 61a6cc11..313d8d95 100644 --- a/kernel/sy_old/mars_main.c +++ b/kernel/sy_old/mars_main.c @@ -254,16 +254,33 @@ void clear_vals(struct key_value_pair *start) } static -void show_vals(struct key_value_pair *start, const char *path, const char *add) +void _show_vals(struct key_value_pair *start, + const char *path, + const char *add, + bool silent) { while (start->key) { char *dst = path_make("%s/actual-%s/msg-%s%s", path, my_id(), add, start->key); + // show the old message for some keep_time if no new one is available if (!start->val && start->old_val && (long long)start->last_jiffies + mars_keep_msg * HZ <= (long long)jiffies) { start->val = start->old_val; start->old_val = NULL; } + if (silent) { + brick_string_free(start->val); + /* remove old message with minimum update frequency */ + if (!compat_deletions) { + const char *check = ordered_readlink(dst, NULL); + bool gone = (!check || !*check); + + brick_string_free(check); + if (gone) + ordered_symlink(MARS_DELETED_STR, dst, NULL); + goto done; + } + } if (start->val) { char *src = path_make("%ld.%09ld %ld.%09ld %s", start->system_stamp.tv_sec, start->system_stamp.tv_nsec, @@ -280,11 +297,18 @@ void show_vals(struct key_value_pair *start, const char *path, const char *add) memset(&start->lamport_stamp, 0, sizeof(start->lamport_stamp)); brick_string_free(start->old_val); } + done: brick_string_free(dst); start++; } } +static inline +void show_vals(struct key_value_pair *start, const char *path, const char *add) +{ + _show_vals(start, path, add, false); +} + static inline void assign_keys(struct key_value_pair *start, const char **keys) {