diff options
author | David Teigland <teigland@redhat.com> | 2009-06-12 11:53:46 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2009-06-12 11:53:46 -0500 |
commit | 677666b500e38282d219fc2dc3542d742ad93404 (patch) | |
tree | 62d37477e904b4334f8b278fcb4a8556054f72da | |
parent | 5f5bea72db19d9428eb093313eb1409ac02dcbc0 (diff) | |
download | dct-stuff-677666b500e38282d219fc2dc3542d742ad93404.tar.gz dct-stuff-677666b500e38282d219fc2dc3542d742ad93404.tar.xz dct-stuff-677666b500e38282d219fc2dc3542d742ad93404.zip |
cpgx: write debug buffer to stderr on error
If an error occurs with debug/event output is disabled (-D0 -H0),
then print the buffer of debug/event output to stderr before exit(1).
The buffer is still written to /var/log/cluster/cpgx_debug.txt.
Signed-off-by: David Teigland <teigland@redhat.com>
-rw-r--r-- | cpgx/cpgx.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/cpgx/cpgx.c b/cpgx/cpgx.c index e574f87..29a8ece 100644 --- a/cpgx/cpgx.c +++ b/cpgx/cpgx.c @@ -1596,9 +1596,9 @@ void loop(void) log_error("no cpg dispatch in %d sec", timeout_sec); if (got_error) { + dump_write(); fflush(stdout); fflush(stderr); - dump_write(); exit(EXIT_FAILURE); } @@ -1902,12 +1902,22 @@ void dump_write(void) fprintf(fp, "cpgx %s - %s\n", begin, end); - if (dump_wrap) + if (!opt_print_event || !opt_print_debug) + fprintf(stderr, "cpgx %s - %s\n", begin, end); + + if (dump_wrap) { fprintf(fp, "%s", dump_buf + dump_point); + if (!opt_print_event || !opt_print_debug) + fprintf(stderr, "%s", dump_buf + dump_point); + } + dump_buf[dump_point] = '\0'; fprintf(fp, "%s", dump_buf); + if (!opt_print_event || !opt_print_debug) + fprintf(stderr, "%s", dump_buf); + fflush(fp); fclose(fp); } |