mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 23:13:26 +00:00
tools: acrn-manager: remove unnecessary "current" field
Remove the unnecessary "current" field when store/load timer list. Tracked-On: #927 Signed-off-by: Yan, Like <like.yan@intel.com> Acked-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
parent
0ca90ba6be
commit
f42209c567
@ -146,11 +146,9 @@ static int load_timer_list(void)
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct work_arg arg = {};
|
struct work_arg arg = {};
|
||||||
time_t expire;
|
time_t expire, current;
|
||||||
time_t record;
|
|
||||||
time_t current;
|
|
||||||
char l[256];
|
char l[256];
|
||||||
char s1[16], s2[64], s3[64]; /* vmname & expire */
|
char s1[16], s2[64]; /* vmname & expire */
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&timer_file_mutex);
|
pthread_mutex_lock(&timer_file_mutex);
|
||||||
@ -162,17 +160,14 @@ static int load_timer_list(void)
|
|||||||
goto open_file_err;
|
goto open_file_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = time(NULL);
|
|
||||||
|
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
memset(l, 0, 256);
|
memset(l, 0, 256);
|
||||||
fgets(l, 255, fp);
|
fgets(l, 255, fp);
|
||||||
|
|
||||||
memset(s1, 0, 16);
|
memset(s1, 0, 16);
|
||||||
memset(s2, 0, 64);
|
memset(s2, 0, 64);
|
||||||
memset(s3, 0, 64);
|
|
||||||
|
|
||||||
sscanf(l, "%s\t%s\t%s", s1, s2, s3);
|
sscanf(l, "%s\t%s", s1, s2);
|
||||||
|
|
||||||
if (strlen(s1) == 0 || strlen(s1) > 16) {
|
if (strlen(s1) == 0 || strlen(s1) > 16) {
|
||||||
perror("Invalid vmname from timer list file");
|
perror("Invalid vmname from timer list file");
|
||||||
@ -188,15 +183,7 @@ static int load_timer_list(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
record = strtoul(s3, NULL, 10);
|
current = time(NULL);
|
||||||
if (record == 0 || errno == ERANGE) {
|
|
||||||
perror("Invalid record time from timer list file");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current == (time_t) -1)
|
|
||||||
current = record;
|
|
||||||
|
|
||||||
if (expire > current)
|
if (expire > current)
|
||||||
expire -= current;
|
expire -= current;
|
||||||
else
|
else
|
||||||
@ -376,15 +363,8 @@ static int store_timer_list(void)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct acrnd_work *w, *twork;
|
struct acrnd_work *w, *twork;
|
||||||
time_t sys_wakeup = 0;
|
time_t sys_wakeup = 0;
|
||||||
time_t current;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
current = time(NULL);
|
|
||||||
if (current == (time_t) - 1) {
|
|
||||||
pdebug();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_lock(&timer_file_mutex);
|
pthread_mutex_lock(&timer_file_mutex);
|
||||||
fp = fopen(TIMER_LIST_FILE, "w+");
|
fp = fopen(TIMER_LIST_FILE, "w+");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
@ -400,7 +380,7 @@ static int store_timer_list(void)
|
|||||||
sys_wakeup = w->expire;
|
sys_wakeup = w->expire;
|
||||||
if (w->expire < sys_wakeup)
|
if (w->expire < sys_wakeup)
|
||||||
sys_wakeup = w->expire;
|
sys_wakeup = w->expire;
|
||||||
fprintf(fp, "%s\t%lu\t%lu\n", w->arg.name, w->expire, current);
|
fprintf(fp, "%s\t%lu\n", w->arg.name, w->expire);
|
||||||
|
|
||||||
/* remove work from list after it's saved onto fs */
|
/* remove work from list after it's saved onto fs */
|
||||||
LIST_REMOVE(w, list);
|
LIST_REMOVE(w, list);
|
||||||
|
Loading…
Reference in New Issue
Block a user