diff --git a/Makefile.am b/Makefile.am index f4ed5e1d..2c3230e0 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 201ab2b0..36b3ddf8 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 a88f2b7a..8e201c9c 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