Doesn't start sync if Ctrl+C is pressed.

This commit is contained in:
Andrea Mazzoleni 2013-07-10 19:37:58 +02:00
parent 7fa93e6c98
commit cefe021e60
3 changed files with 13 additions and 3 deletions

12
state.c
View file

@ -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)

View file

@ -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.

2
sync.c
View file

@ -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<blockmax;++i) {
int one_invalid;
int one_valid;