From cefe021e608577af8c042b55a2a72da47e224a11 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 10 Jul 2013 19:37:58 +0200 Subject: [PATCH] Doesn't start sync if Ctrl+C is pressed. --- state.c | 12 +++++++++++- state.h | 2 +- sync.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/state.c b/state.c index 8e9ed3ff..bd38a5de 100644 --- a/state.c +++ b/state.c @@ -2240,7 +2240,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom } } -void state_progress_begin(struct snapraid_state* state, block_off_t blockstart, block_off_t blockmax, block_off_t countmax) +int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, block_off_t blockmax, block_off_t countmax) { if (state->opt.gui) { fprintf(stdlog,"run:begin:%u:%u:%u\n", blockstart, blockmax, countmax); @@ -2254,6 +2254,16 @@ void state_progress_begin(struct snapraid_state* state, block_off_t blockstart, state->progress_last = now; state->progress_subtract = 0; } + + /* stop if requested */ + if (global_interrupt) { + if (!state->opt.gui) { + printf("Not starting for interruption\n"); + } + return 0; + } + + return 1; } void state_progress_end(struct snapraid_state* state, block_off_t countpos, block_off_t countmax, data_off_t countsize) diff --git a/state.h b/state.h index aaf7df07..c3ffe115 100644 --- a/state.h +++ b/state.h @@ -174,7 +174,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom /** * Begins the progress visualization. */ -void state_progress_begin(struct snapraid_state* state, block_off_t blockstart, block_off_t blockmax, block_off_t countmax); +int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, block_off_t blockmax, block_off_t countmax); /** * Ends the progress visualization. diff --git a/sync.c b/sync.c index 3e94f088..d53dd553 100644 --- a/sync.c +++ b/sync.c @@ -116,7 +116,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari countsize = 0; countpos = 0; - state_progress_begin(state, blockstart, blockmax, countmax); + if (state_progress_begin(state, blockstart, blockmax, countmax)) for(i=blockstart;i