main: allow silent reporting

This commit is contained in:
Thomas Schoebel-Theuer 2020-10-30 16:51:05 +01:00
parent fb186be1f1
commit a11f8666a3
1 changed files with 25 additions and 1 deletions

View File

@ -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)
{