summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Toman <mtoman@redhat.com>2011-05-20 13:43:31 +0200
committerMichal Toman <mtoman@redhat.com>2011-05-20 13:43:31 +0200
commitee2ca731d693d6677efba5699faa09a9be5d50fd (patch)
tree214b7bcd0e0d04ce33b71de0f4c4655402a55fa5
parent15263908a962ff510b97066fed6f6fa541f5ab46 (diff)
downloadabrt-ee2ca731d693d6677efba5699faa09a9be5d50fd.tar.gz
abrt-ee2ca731d693d6677efba5699faa09a9be5d50fd.tar.xz
abrt-ee2ca731d693d6677efba5699faa09a9be5d50fd.zip
retrace client: add --status-delay option (and be more verbose - trac #269)
-rw-r--r--src/plugins/abrt-retrace-client.c76
-rw-r--r--src/plugins/abrt-retrace-client.txt10
2 files changed, 76 insertions, 10 deletions
diff --git a/src/plugins/abrt-retrace-client.c b/src/plugins/abrt-retrace-client.c
index 524fa186..2fa1ea44 100644
--- a/src/plugins/abrt-retrace-client.c
+++ b/src/plugins/abrt-retrace-client.c
@@ -47,6 +47,7 @@ static const char *required_files[] = { FILENAME_COREDUMP,
NULL };
static bool ssl_allow_insecure = false;
static bool http_show_headers = false;
+static unsigned delay = 0;
/* Add an entry name to the args array if the entry name exists in a
* dump directory. The entry is added to argindex offset to the array,
@@ -536,6 +537,12 @@ static int create(bool delete_temp_archive,
char **task_id,
char **task_password)
{
+ if (delay)
+ {
+ puts("Querying server settings");
+ fflush(stdout);
+ }
+
struct retrace_settings settings;
get_settings(&settings);
@@ -585,6 +592,12 @@ static int create(bool delete_temp_archive,
unpacked_size, settings.max_unpacked_size);
}
+ if (delay)
+ {
+ puts("Preparing an archive to upload");
+ fflush(stdout);
+ }
+
int tempfd = create_archive(delete_temp_archive);
if (-1 == tempfd)
return 1;
@@ -619,11 +632,38 @@ static int create(bool delete_temp_archive,
error_msg_and_die("Failed to send HTTP header of length %d: NSS error %d",
http_request->len, PR_GetError());
}
+
+ if (delay)
+ {
+ printf("Uploading %lld bytes\n", (long long)file_stat.st_size);
+ fflush(stdout);
+ }
+
strbuf_free(http_request);
int result = 0;
- while (1)
+ int i;
+ char buf[32768];
+
+ time_t start, now;
+ time(&start);
+
+ for (i = 0;; ++i)
{
- char buf[32768];
+ if (delay)
+ {
+ time(&now);
+ if (now - start >= delay)
+ {
+ time(&start);
+ int progress = 100 * i * sizeof(buf) / file_stat.st_size;
+ if (progress > 100)
+ continue;
+
+ printf("Uploading %d%%\n", progress);
+ fflush(stdout);
+ }
+ }
+
int r = read(tempfd, buf, sizeof(buf));
if (r <= 0)
{
@@ -651,6 +691,13 @@ static int create(bool delete_temp_archive,
}
}
close(tempfd);
+
+ if (delay)
+ {
+ puts("Upload successful");
+ fflush(stdout);
+ }
+
/* Read the HTTP header of the response from server. */
char *http_response = tcp_read_response(tcp_sock);
char *http_body = http_get_body(http_response);
@@ -672,6 +719,13 @@ static int create(bool delete_temp_archive,
error_msg_and_die("Invalid response from server: missing X-Task-Password");
free(http_response);
ssl_disconnect(ssl_sock);
+
+ if (delay)
+ {
+ puts("Retrace job started");
+ fflush(stdout);
+ }
+
return result;
}
@@ -837,11 +891,12 @@ static int run_batch(bool delete_temp_archive)
return retcode;
char *task_status = xstrdup("");
char *status_message = xstrdup("");
+ int status_delay = delay ? delay : 10;
while (0 != strncmp(task_status, "FINISHED", strlen("finished")))
{
free(task_status);
free(status_message);
- sleep(10);
+ sleep(status_delay);
status(task_id, task_password, &task_status, &status_message);
puts(status_message);
fflush(stdout);
@@ -890,10 +945,11 @@ int main(int argc, char **argv)
OPT_group_1 = 1 << 5,
OPT_dir = 1 << 6,
OPT_core = 1 << 7,
- OPT_no_unlink = 1 << 8,
- OPT_group_2 = 1 << 9,
- OPT_task = 1 << 10,
- OPT_password = 1 << 11
+ OPT_delay = 1 << 8,
+ OPT_no_unlink = 1 << 9,
+ OPT_group_2 = 1 << 10,
+ OPT_task = 1 << 11,
+ OPT_password = 1 << 12
};
/* Keep enum above and order of options below in sync! */
@@ -911,6 +967,8 @@ int main(int argc, char **argv)
"read data from ABRT crash dump directory"),
OPT_STRING('c', "core", &coredump, "COREDUMP",
"read data from coredump"),
+ OPT_INTEGER('l', "status-delay", &delay,
+ "Delay for polling operations"),
OPT_BOOL(0, "no-unlink", NULL,
"(debug) do not delete temporary archive created"
" from dump dir in /tmp"),
@@ -929,6 +987,10 @@ int main(int argc, char **argv)
if (env_url)
url = env_url;
+ char *env_delay = getenv("ABRT_STATUS_DELAY");
+ if (env_delay)
+ delay = xatou(env_delay);
+
unsigned opts = parse_opts(argc, argv, options, usage);
if (opts & OPT_syslog)
{
diff --git a/src/plugins/abrt-retrace-client.txt b/src/plugins/abrt-retrace-client.txt
index 9ae536bd..30971159 100644
--- a/src/plugins/abrt-retrace-client.txt
+++ b/src/plugins/abrt-retrace-client.txt
@@ -43,9 +43,10 @@ backtrace::
batch::
Runs all operations in one step: creates a new task, periodically
- asks for status and downloads the result when finished. If the task
- was successful, backtrace file is saved, otherwise log is printed
- to stdout. Either -c or -d is required.
+ asks for status (the period is specified by --status-delay option)
+ and downloads the result when finished. If the task was successful
+ backtrace file is saved, otherwise log is printed to stdout.
+ Either -c or -d is required.
OPTIONS
-------
@@ -70,6 +71,9 @@ OPTIONS
-c, --core COREDUMP::
read data from coredump
+-l, --status-delay::
+ delay for polling operations (seconds)
+
--no-unlink::
(debug) do not delete temporary archive created in /tmp