Commit 2259bfcd7db4ce4979ddc9e117499b3aa23eeb78

Con Kolivas 2014-03-05T22:37:40

Merge branch 'master' of github.com:ckolivas/cgminer

diff --git a/README b/README
index 3cecbce..29c3dba 100644
--- a/README
+++ b/README
@@ -102,7 +102,8 @@ If building on Red Hat:
                          curl libcurl libcurl-devel openssh
 
 If building on Ubuntu:
-	sudo apt-get install build-essential autoconf automake libtool libcurl3-dev libudev-dev
+	sudo apt-get install build-essential autoconf automake libtool pkg-config \
+                             libcurl3-dev libudev-dev
 
 CGMiner specific configuration options:
   --enable-ants1          Compile support for Antminer S1 Bitmain (default
diff --git a/cgminer.c b/cgminer.c
index c2d56e7..ece6778 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3560,7 +3560,7 @@ static void __kill_work(void)
 /* This should be the common exit path */
 void kill_work(void)
 {
-	__kill_work();
+	cg_completion_timeout(&__kill_work, NULL, 5000);
 
 	quit(0, "Shutdown signal received.");
 }
@@ -3577,7 +3577,7 @@ void app_restart(void)
 {
 	applog(LOG_WARNING, "Attempting to restart %s", packagename);
 
-	__kill_work();
+	cg_completion_timeout(&__kill_work, NULL, 5000);
 	clean_up(true);
 
 #if defined(unix) || defined(__APPLE__)
@@ -7953,8 +7953,24 @@ static void clean_up(bool restarting)
 	curl_global_cleanup();
 }
 
+/* Should all else fail and we're unable to clean up threads due to locking
+ * issues etc, just silently exit. */
+static void *killall_thread(void __maybe_unused *arg)
+{
+	pthread_detach(pthread_self());
+	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+	sleep(5);
+	exit(1);
+	return NULL;
+}
+
 void __quit(int status, bool clean)
 {
+	pthread_t killall_t;
+
+	if (unlikely(pthread_create(&killall_t, NULL, killall_thread, NULL)))
+		exit(1);
+
 	if (clean)
 		clean_up(false);
 #ifdef HAVE_CURSES
@@ -7968,6 +7984,7 @@ void __quit(int status, bool clean)
 		forkpid = 0;
 	}
 #endif
+	pthread_cancel(killall_t);
 
 	exit(status);
 }
diff --git a/driver-hashfast.c b/driver-hashfast.c
index cf053d5..c7a9b69 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -650,26 +650,27 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
 	if (!ret) {
 		/* We should receive a valid header even if OP_NAME isn't
 		 * supported by the firmware. */
-		applog(LOG_WARNING, "%s: Failed to receive OP_NAME response", hashfast->drv->name);
-		goto out;
-	}
-
-	/* Only try to parse the name if the firmware supports OP_NAME */
-	if (h->operation_code == OP_NAME) {
-		if (!hfa_get_data(hashfast, info->op_name, 32 / 4)) {
-			applog(LOG_WARNING, "%s %d: OP_NAME failed! Failure to get op_name data",
-			       hashfast->drv->name, hashfast->device_id);
-			goto out;
-		}
-		info->has_opname = info->opname_valid = true;
-		applog(LOG_DEBUG, "%s: Returned an OP_NAME", hashfast->drv->name);
-		for (i = 0; i < 32; i++) {
-			if (i > 0 && info->op_name[i] == '\0')
-				break;
-			/* Make sure the op_name is valid ascii only */
-			if (info->op_name[i] < 32 || info->op_name[i] > 126) {
-				info->opname_valid = false;
-				break;
+		applog(LOG_NOTICE, "%s %d: Firmware upgrade required to support module Naming.",
+			hashfast->drv->name, hashfast->device_id);
+		ret = true;
+	} else {
+		/* Only try to parse the name if the firmware supports OP_NAME */
+		if (h->operation_code == OP_NAME) {
+			if (!hfa_get_data(hashfast, info->op_name, 32 / 4)) {
+				applog(LOG_WARNING, "%s %d: OP_NAME failed! Failure to get op_name data",
+			       	hashfast->drv->name, hashfast->device_id);
+				goto out;
+			}
+			info->has_opname = info->opname_valid = true;
+			applog(LOG_DEBUG, "%s: Returned an OP_NAME", hashfast->drv->name);
+			for (i = 0; i < 32; i++) {
+				if (i > 0 && info->op_name[i] == '\0')
+					break;
+				/* Make sure the op_name is valid ascii only */
+				if (info->op_name[i] < 32 || info->op_name[i] > 126) {
+					info->opname_valid = false;
+					break;
+				}
 			}
 		}
 	}