Browse Source

Merge commit '448f8dd' into cg_merges_20131108a

Conflicts:
	miner.c
Luke Dashjr 12 years ago
parent
commit
e9d47e748d
2 changed files with 12 additions and 8 deletions
  1. 2 2
      logging.h
  2. 10 6
      miner.c

+ 2 - 2
logging.h

@@ -103,10 +103,10 @@ extern void _applog(int prio, const char *str);
 	return rv;  \
 } while (0)
 
-extern void _bfg_clean_up(void);
+extern void _bfg_clean_up(bool);
 
 #define quit(status, fmt, ...) do { \
-	_bfg_clean_up();  \
+	_bfg_clean_up(false);  \
 	if (fmt) { \
 		fprintf(stderr, fmt, ##__VA_ARGS__);  \
 	} \

+ 10 - 6
miner.c

@@ -4566,14 +4566,14 @@ const
 #endif
 char **initial_args;
 
-void _bfg_clean_up(void);
+void _bfg_clean_up(bool);
 
 void app_restart(void)
 {
 	applog(LOG_WARNING, "Attempting to restart %s", packagename);
 
 	__kill_work();
-	_bfg_clean_up();
+	_bfg_clean_up(true);
 
 #if defined(unix) || defined(__APPLE__)
 	if (forkpid > 0) {
@@ -9736,7 +9736,7 @@ void print_summary(void)
 	fflush(stdout);
 }
 
-void _bfg_clean_up(void)
+void _bfg_clean_up(bool restarting)
 {
 #ifdef HAVE_OPENCL
 	clear_adl(nDevs);
@@ -9750,11 +9750,15 @@ void _bfg_clean_up(void)
 #ifdef WIN32
 	timeEndPeriod(1);
 #endif
+	if (!restarting) {
+		/* Attempting to disable curses or print a summary during a
+		 * restart can lead to a deadlock. */
 #ifdef HAVE_CURSES
-	disable_curses();
+		disable_curses();
 #endif
-	if (!opt_realquiet && successful_connect)
-		print_summary();
+		if (!opt_realquiet && successful_connect)
+			print_summary();
+	}
 
 	if (opt_n_threads)
 		free(cpus);