Browse Source

Bugfix: Cleanup needs to happen before printing the final quit message, or it gets lost in TUI mode

Luke Dashjr 12 years ago
parent
commit
5f432d1ba0
2 changed files with 9 additions and 8 deletions
  1. 6 3
      logging.h
  2. 3 5
      miner.c

+ 6 - 3
logging.h

@@ -54,12 +54,15 @@ extern void _applog(int prio, const char *str);
 	return rv;  \
 	return rv;  \
 } while (0)
 } while (0)
 
 
+extern void _bfg_clean_up(void);
+
 #define quit(status, fmt, ...) do { \
 #define quit(status, fmt, ...) do { \
+	_bfg_clean_up();  \
 	if (fmt) { \
 	if (fmt) { \
-		char tmp42[LOGBUFSIZ]; \
-		snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \
-		_applog(LOG_ERR, tmp42); \
+		fprintf(stderr, fmt, ##__VA_ARGS__);  \
 	} \
 	} \
+	fprintf(stderr, "\n");  \
+	fflush(stderr);  \
 	_quit(status); \
 	_quit(status); \
 } while (0)
 } while (0)
 
 

+ 3 - 5
miner.c

@@ -3633,14 +3633,14 @@ const
 #endif
 #endif
 char **initial_args;
 char **initial_args;
 
 
-static void clean_up(void);
+void _bfg_clean_up(void);
 
 
 void app_restart(void)
 void app_restart(void)
 {
 {
 	applog(LOG_WARNING, "Attempting to restart %s", packagename);
 	applog(LOG_WARNING, "Attempting to restart %s", packagename);
 
 
 	__kill_work();
 	__kill_work();
-	clean_up();
+	_bfg_clean_up();
 
 
 #if defined(unix) || defined(__APPLE__)
 #if defined(unix) || defined(__APPLE__)
 	if (forkpid > 0) {
 	if (forkpid > 0) {
@@ -8162,7 +8162,7 @@ void print_summary(void)
 	fflush(stdout);
 	fflush(stdout);
 }
 }
 
 
-static void clean_up(void)
+void _bfg_clean_up(void)
 {
 {
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
 	clear_adl(nDevs);
 	clear_adl(nDevs);
@@ -8186,8 +8186,6 @@ static void clean_up(void)
 
 
 void _quit(int status)
 void _quit(int status)
 {
 {
-	clean_up();
-
 	if (status) {
 	if (status) {
 		const char *ev = getenv("__BFGMINER_SEGFAULT_ERRQUIT");
 		const char *ev = getenv("__BFGMINER_SEGFAULT_ERRQUIT");
 		if (unlikely(ev && ev[0] && ev[0] != '0')) {
 		if (unlikely(ev && ev[0] && ev[0] != '0')) {