Merge pull request #11 from philsmd/master

implements the enhancement mentioned in issue #10 (cancel on next checkpoint)
pull/12/head
Jens Steube 9 years ago
commit 4c6b41d83f

@ -1883,15 +1883,16 @@ extern hc_thread_mutex_t mux_display;
* status
*/
#define STATUS_STARTING 0
#define STATUS_INIT 1
#define STATUS_RUNNING 2
#define STATUS_PAUSED 3
#define STATUS_EXHAUSTED 4
#define STATUS_CRACKED 5
#define STATUS_ABORTED 6
#define STATUS_QUIT 7
#define STATUS_BYPASS 8
#define STATUS_STARTING 0
#define STATUS_INIT 1
#define STATUS_RUNNING 2
#define STATUS_PAUSED 3
#define STATUS_EXHAUSTED 4
#define STATUS_CRACKED 5
#define STATUS_ABORTED 6
#define STATUS_QUIT 7
#define STATUS_BYPASS 8
#define STATUS_STOP_AT_CHECKPOINT 9
#define ST_0000 "Initializing"
#define ST_0001 "Starting"
@ -1902,6 +1903,7 @@ extern hc_thread_mutex_t mux_display;
#define ST_0006 "Aborted"
#define ST_0007 "Quit"
#define ST_0008 "Bypass"
#define ST_0009 "Running (stop at checkpoint)"
/**
* kernel types
@ -2234,6 +2236,7 @@ restore_data_t *init_restore (int argc, char **argv);
void read_restore (const char *eff_restore_file, restore_data_t *rd);
void write_restore (const char *new_restore_file, restore_data_t *rd);
void cycle_restore ();
void check_checkpoint ();
#ifdef WIN

@ -1206,6 +1206,8 @@ typedef struct
restore_data_t *rd;
uint64_t checkpoint_cur_words; // used for the "stop at next checkpoint" feature
/**
* status, timer
*/

@ -315,7 +315,7 @@ hc_thread_mutex_t mux_display;
hc_global_data_t data;
const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [q]uit => ";
const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint stop [q]uit => ";
const char *USAGE_MINI[] =
{
@ -1482,7 +1482,7 @@ void status_display ()
if (data.restore_disable == 0)
{
log_info ("Restore point..: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
log_info ("Restore.Point..: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
}
}
else
@ -1494,7 +1494,7 @@ void status_display ()
//if (data.restore_disable == 0)
//{
// log_info ("Restore point..: %llu", (unsigned long long int) restore_point);
// log_info ("Restore.Point..: %llu", (unsigned long long int) restore_point);
//}
}
}
@ -2797,6 +2797,8 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
{
while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -2823,6 +2825,8 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
{
while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -3080,6 +3084,8 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
run_kernel (KERN_RUN_2, device_param, pws_cnt);
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -3116,6 +3122,8 @@ static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, con
run_kernel (KERN_RUN_3, device_param, pws_cnt);
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -4954,6 +4962,8 @@ static void *thread_calc (void *p)
device_param->pws_cnt = 0;
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -5127,18 +5137,24 @@ static void *thread_calc (void *p)
device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -5197,6 +5213,8 @@ static void *thread_calc (void *p)
device_param->pws_cnt = 0;
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -5250,6 +5268,8 @@ static void *thread_calc (void *p)
device_param->pws_cnt = 0;
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -17369,6 +17389,7 @@ int main (int argc, char **argv)
hc_thread_wait (devices_cnt, c_threads);
local_free (c_threads);
data.restore = 0;
@ -17377,6 +17398,8 @@ int main (int argc, char **argv)
logfile_sub_var_uint ("status-after-work", data.devices_status);
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
@ -17454,6 +17477,8 @@ int main (int argc, char **argv)
global_free (subid);
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
@ -17952,10 +17977,11 @@ int main (int argc, char **argv)
if (quiet == 0) log_info_nn ("Started: %s", ctime (&proc_start));
if (quiet == 0) log_info_nn ("Stopped: %s", ctime (&proc_stop));
if (data.devices_status == STATUS_ABORTED) return 2;
if (data.devices_status == STATUS_QUIT) return 2;
if (data.devices_status == STATUS_EXHAUSTED) return 1;
if (data.devices_status == STATUS_CRACKED) return 0;
if (data.devices_status == STATUS_ABORTED) return 2;
if (data.devices_status == STATUS_QUIT) return 2;
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) return 2;
if (data.devices_status == STATUS_EXHAUSTED) return 1;
if (data.devices_status == STATUS_CRACKED) return 0;
return -1;
}

@ -5570,14 +5570,16 @@ char *strstatus (const uint devices_status)
{
switch (devices_status)
{
case STATUS_INIT: return ((char *) ST_0000); break;
case STATUS_STARTING: return ((char *) ST_0001); break;
case STATUS_RUNNING: return ((char *) ST_0002); break;
case STATUS_PAUSED: return ((char *) ST_0003); break;
case STATUS_EXHAUSTED: return ((char *) ST_0004); break;
case STATUS_CRACKED: return ((char *) ST_0005); break;
case STATUS_ABORTED: return ((char *) ST_0006); break;
case STATUS_QUIT: return ((char *) ST_0007); break;
case STATUS_INIT: return ((char *) ST_0000); break;
case STATUS_STARTING: return ((char *) ST_0001); break;
case STATUS_RUNNING: return ((char *) ST_0002); break;
case STATUS_PAUSED: return ((char *) ST_0003); break;
case STATUS_EXHAUSTED: return ((char *) ST_0004); break;
case STATUS_CRACKED: return ((char *) ST_0005); break;
case STATUS_ABORTED: return ((char *) ST_0006); break;
case STATUS_QUIT: return ((char *) ST_0007); break;
case STATUS_BYPASS: return ((char *) ST_0008); break;
case STATUS_STOP_AT_CHECKPOINT: return ((char *) ST_0009); break;
}
return ((char *) "Unknown");
@ -8360,6 +8362,28 @@ void bypass ()
log_info ("Next dictionary / mask in queue selected, bypassing current one");
}
void stop_at_checkpoint ()
{
if (data.devices_status != STATUS_RUNNING) return;
// this feature only makes sense if --restore-disable was not specified
if (data.restore_disable == 0)
{
data.devices_status = STATUS_STOP_AT_CHECKPOINT;
// save the current restore point value
data.checkpoint_cur_words = get_lowest_words_done ();
log_info ("Stop at next checkpoint");
}
else
{
log_info ("WARNING: this feature is disabled when --restore-disable was specified");
}
}
void myabort ()
{
if (data.devices_status == STATUS_INIT) return;
@ -8772,6 +8796,18 @@ void cycle_restore ()
}
}
void check_checkpoint ()
{
// if (data.restore_disable == 1) break; (this is already implied by previous checks)
uint64_t words_cur = get_lowest_words_done ();
if (words_cur != data.checkpoint_cur_words)
{
myabort ();
}
}
/**
* adjustments
*/
@ -18713,6 +18749,21 @@ void *thread_keypress (void *p)
break;
case 'c':
log_info ("");
if (benchmark == 1) break;
stop_at_checkpoint ();
log_info ("");
if (quiet == 0) fprintf (stdout, "%s", PROMPT);
if (quiet == 0) fflush (stdout);
break;
case 'q':
log_info ("");

Loading…
Cancel
Save