From ecf007b3a2c45d0eb5060ca1e204d20af0c89fc0 Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Wed, 16 Mar 2011 11:06:27 +0100 Subject: [PATCH] qfile-agent writes DONE to the status file at the end of work. --- appvm/qfile-agent.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/appvm/qfile-agent.c b/appvm/qfile-agent.c index 71c86e5f..f7e27a98 100644 --- a/appvm/qfile-agent.c +++ b/appvm/qfile-agent.c @@ -12,8 +12,16 @@ #include #include "filecopy.h" +enum { + PROGRESS_FLAG_NORMAL, + PROGRESS_FLAG_INIT, + PROGRESS_FLAG_DONE +}; + + + char *client_flags; -void do_notify_progress(long long total) +void do_notify_progress(long long total, int flag) { FILE *progress; if (!client_flags[0]) @@ -21,17 +29,19 @@ void do_notify_progress(long long total) progress = fopen(client_flags, "w"); if (!progress) return; - fprintf(progress, "%d %lld", getpid(), total); + fprintf(progress, "%d %lld %s", getpid(), total, + flag == PROGRESS_FLAG_DONE ? "DONE" : "BUSY"); fclose(progress); } -void notify_progress(int size, int force) +void notify_progress(int size, int flag) { static long long total = 0; static long long prev_total = 0; total += size; - if (total > prev_total + PROGRESS_NOTIFY_DELTA || force) { - do_notify_progress(total); + if (total > prev_total + PROGRESS_NOTIFY_DELTA + || (flag != PROGRESS_FLAG_NORMAL)) { + do_notify_progress(total, flag); prev_total = total; } } @@ -139,7 +149,7 @@ void parse_entry(char *data, int datasize) char *vmname, *entry, *sep; vmname = get_item(data, ¤t, datasize); client_flags = get_item(data, ¤t, datasize); - notify_progress(0, 1); + notify_progress(0, PROGRESS_FLAG_INIT); send_vmname(vmname); while ((entry = get_item(data, ¤t, datasize))) { do { @@ -155,7 +165,7 @@ void parse_entry(char *data, int datasize) gui_fatal("chdir to %s", entry); do_fs_walk(sep + 1); } - notify_progress(0, 1); + notify_progress(0, PROGRESS_FLAG_DONE); } void process_spoolentry(char *entry_name)