Merge branch 'master' into usb-dev
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
diff --git a/cgminer.c b/cgminer.c
index 85f745d..7eeb1bc 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6061,7 +6061,7 @@ static void *watchpool_thread(void __maybe_unused *userdata)
/* Makes sure the hashmeter keeps going even if mining threads stall, updates
* the screen at regular intervals, and restarts threads if they appear to have
* died. */
-#define WATCHDOG_INTERVAL 3
+#define WATCHDOG_INTERVAL 2
#define WATCHDOG_SICK_TIME 60
#define WATCHDOG_DEAD_TIME 600
#define WATCHDOG_SICK_COUNT (WATCHDOG_SICK_TIME/WATCHDOG_INTERVAL)
diff --git a/util.c b/util.c
index 17fb1ce..056984e 100644
--- a/util.c
+++ b/util.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2012 Con Kolivas
+ * Copyright 2011-2013 Con Kolivas
* Copyright 2010 Jeff Garzik
*
* This program is free software; you can redistribute it and/or modify it
@@ -1450,6 +1450,34 @@ static bool setup_stratum_curl(struct pool *pool)
return true;
}
+static char *get_sessionid(json_t *val)
+{
+ char *ret = NULL;
+ json_t *arr_val;
+ int arrsize, i;
+
+ arr_val = json_array_get(val, 0);
+ if (!arr_val || !json_is_array(arr_val))
+ goto out;
+ arrsize = json_array_size(arr_val);
+ for (i = 0; i < arrsize; i++) {
+ json_t *arr = json_array_get(arr_val, i);
+ char *notify;
+
+ if (!arr | !json_is_array(arr))
+ break;
+ notify = __json_array_string(arr, 0);
+ if (!notify)
+ continue;
+ if (!strncasecmp(notify, "mining.notify", 13)) {
+ ret = json_array_string(arr, 1);
+ break;
+ }
+ }
+out:
+ return ret;
+}
+
bool initiate_stratum(struct pool *pool)
{
char s[RBUFSIZE], *sret = NULL, *nonce1, *sessionid;
@@ -1462,9 +1490,12 @@ bool initiate_stratum(struct pool *pool)
goto out;
resend:
- if (pool->sessionid)
- sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\"%s\"]}", swork_id++, pool->sessionid);
- else
+ if (!recvd) {
+ if (pool->sessionid)
+ sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\", \"%s\"]}", swork_id++, pool->sessionid);
+ else
+ sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\"]}", swork_id++);
+ } else
sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++);
if (!__stratum_send(pool, s, strlen(s))) {
@@ -1509,7 +1540,7 @@ resend:
goto out;
}
- sessionid = json_array_string(json_array_get(res_val, 0), 1);
+ sessionid = get_sessionid(res_val);
if (!sessionid)
applog(LOG_DEBUG, "Failed to get sessionid in initiate_stratum");
nonce1 = json_array_string(res_val, 1);
@@ -1551,7 +1582,7 @@ out:
pool->pool_no, pool->nonce1, pool->n2size);
}
} else {
- if (recvd && pool->sessionid) {
+ if (recvd) {
/* Reset the sessionid used for stratum resuming in case the pool
* does not support it, or does not know how to respond to the
* presence of the sessionid parameter. */