tools: acrn-crashlog: stop only collecting logs when exceeding configured size

Crashlog would drop all events after the storaged log size exceeds the
configured parameter "foldersize" previously, that basically means all
activities are stopped.

This patch brings other activities back (e.g. the records in the file
"history_event" will be updated continually), and restricts the "foldersize" by
stopping log collection.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
This commit is contained in:
Liu, Xinwu
2019-02-19 15:39:35 +08:00
committed by Eddie Dong
parent e38ff18be3
commit 73e5323261
3 changed files with 48 additions and 76 deletions

View File

@@ -126,38 +126,6 @@ static void watchdog_init(int timeout)
}
}
static int check_folder_space(struct sender_t *sender)
{
size_t dsize;
int cfg_size;
if (dir_size(sender->outdir, sender->outdir_len, &dsize) == -1) {
LOGE("failed to check outdir size, drop ev\n");
return -1;
}
if (cfg_atoi(sender->foldersize, sender->foldersize_len,
&cfg_size) == -1)
return -1;
if (dsize/MB >= (size_t)cfg_size) {
if (sender->suspending)
return -1;
LOGW("suspend (%s), since (%s: %ldM) meets quota (%dM)\n",
sender->name, sender->outdir, dsize/MB, cfg_size);
sender->suspending = 1;
return -1;
}
if (!sender->suspending)
return 0;
LOGW("resume (%s), %s: left space %ldM for storage\n",
sender->name, sender->outdir, cfg_size - dsize/MB);
return 0;
}
/**
* Process each event in event queue.
* Note that currently event handler is single threaded.
@@ -191,9 +159,6 @@ static void *event_handle(void *unused __attribute__((unused)))
if (!sender)
continue;
if (check_folder_space(sender) == -1)
continue;
if (sender->send)
sender->send(e);
}