Merge branch 'master' into gbt
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
diff --git a/Makefile.am b/Makefile.am
index f4ed5e1..2c3230e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,7 @@ cgminer_LDADD = $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ \
@OPENCL_LIBS@ @NCURSES_LIBS@ @PDCURSES_LIBS@ @WS2_LIBS@ \
@UDEV_LIBS@ @USB_LIBS@ \
@MATH_LIBS@ lib/libgnu.a ccan/libccan.a
-cgminer_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib @OPENCL_FLAGS@
+cgminer_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib @OPENCL_FLAGS@ @LIBCURL_CFLAGS@
# common sources
cgminer_SOURCES := cgminer.c
diff --git a/cgminer.c b/cgminer.c
index 201ab2b..36b3ddf 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4608,6 +4608,28 @@ out:
static void pool_resus(struct pool *pool);
+static void clear_stratum_shares(struct pool *pool)
+{
+ struct stratum_share *sshare, *tmpshare;
+ int cleared = 0;
+
+ mutex_lock(&sshare_lock);
+ HASH_ITER(hh, stratum_shares, sshare, tmpshare) {
+ if (sshare->work.pool == pool) {
+ HASH_DEL(stratum_shares, sshare);
+ free(sshare);
+ cleared++;
+ }
+ }
+ mutex_unlock(&sshare_lock);
+
+ if (cleared) {
+ applog(LOG_WARNING, "Lost %d shares due to stratum disconnect on pool %d", cleared, pool->pool_no);
+ pool->stale_shares++;
+ total_stale++;
+ }
+}
+
/* One stratum thread per pool that has stratum waits on the socket checking
* for new messages and for the integrity of the socket connection. We reset
* the connection based on the integrity of the receive side only as the send
@@ -4644,6 +4666,11 @@ static void *stratum_thread(void *userdata)
pool->getfail_occasions++;
total_go++;
+ /* If the socket to our stratum pool disconnects, all
+ * tracked submitted shares are lost and we will leak
+ * the memory if we don't discard their records. */
+ clear_stratum_shares(pool);
+
if (initiate_stratum(pool) && auth_stratum(pool))
continue;
diff --git a/configure.ac b/configure.ac
index a88f2b7..8e201c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,6 +70,9 @@ WS2_LIBS=""
MATH_LIBS="-lm"
case $target in
+ amd64-*)
+ have_x86_64=true
+ ;;
x86_64-*)
have_x86_64=true
;;
@@ -257,7 +260,7 @@ if test "x$curses" = "xno"; then
else
AC_SEARCH_LIBS(addstr, ncurses pdcurses, [
curses=yes
- cursesmsg="FOUND: ${ac_cv_search_addstr:2}"
+ cursesmsg="FOUND: ${ac_cv_search_addstr}"
AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
], [
if test "x$curses" = "xyes"; then