Print summary on quit modes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/main.c b/main.c
index 23e6372..8b483bd 100644
--- a/main.c
+++ b/main.c
@@ -1879,6 +1879,8 @@ static void disable_curses(void)
}
}
+static void print_summary(void);
+
void kill_work(void)
{
struct workio_cmd *wc;
@@ -1928,14 +1930,22 @@ void kill_work(void)
applog(LOG_ERR, "Failed to tq_push work in kill_work");
exit (1);
}
+
+ thr = &thr_info[work_thr_id];
+ if (thr->pth)
+ pthread_cancel(*thr->pth);
}
+void quit(int status, const char *format, ...);
+
static void sighandler(int sig)
{
/* Restore signal handlers so we can still quit if kill_work fails */
sigaction(SIGTERM, &termhandler, NULL);
sigaction(SIGINT, &inthandler, NULL);
kill_work();
+
+ quit(sig, "Received interrupt signal.");
}
static void *get_work_thread(void *userdata)
@@ -2855,6 +2865,8 @@ static void *workio_thread(void *userdata)
struct thr_info *mythr = userdata;
bool ok = true;
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
while (ok) {
struct workio_cmd *wc;
@@ -4432,6 +4444,10 @@ void quit(int status, const char *format, ...)
va_list ap;
disable_curses();
+
+ if (!opt_realquiet && successful_connect)
+ print_summary();
+
if (format) {
va_start(ap, format);
vfprintf(stderr, format, ap);