From 12c768e6fc0abefdb692a3b719ba957e78c903aa Mon Sep 17 00:00:00 2001 From: Thomas Baumbach Date: Thu, 12 Sep 2013 10:56:50 +0200 Subject: [PATCH 1/2] force reconnect on too many rejections --- src/main_poolminer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main_poolminer.cpp b/src/main_poolminer.cpp index 03e1364c..eefa4ade 100644 --- a/src/main_poolminer.cpp +++ b/src/main_poolminer.cpp @@ -254,7 +254,8 @@ public: } socket_to_server = socket.get(); //TODO: lock/mutex - + + int reject_counter = 0; bool done = false; while (!done) { int type = -1; @@ -321,6 +322,15 @@ public: (retval == 0 ? "REJECTED" : retval < 0 ? "STALE" : retval == 1 ? "BLOCK" : "SHARE") << std::endl; std::map::iterator it = statistics.find(retval); + if (retval > 0) + reject_counter = 0; + else + reject_counter++; + if (reject_counter >= 3) { + std::cout << "too many rejects, forcing reconnect." << std::endl; + socket->close(); + done = true; + } if (it == statistics.end()) statistics.insert(std::pair(retval,1)); else From 7b239dde112e40eafed35312cd8281c9736bfe0f Mon Sep 17 00:00:00 2001 From: Thomas Baumbach Date: Thu, 12 Sep 2013 14:33:34 +0200 Subject: [PATCH 2/2] fixed the stats-at-exit for linux, currect defines are used now --- src/main_poolminer.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main_poolminer.cpp b/src/main_poolminer.cpp index eefa4ade..ed8e5adc 100644 --- a/src/main_poolminer.cpp +++ b/src/main_poolminer.cpp @@ -424,7 +424,7 @@ void exit_handler() { running = false; } -#ifdef __MINGW32__ +#ifdef __MINGW__ #define WIN32_LEAN_AND_MEAN #include @@ -446,7 +446,8 @@ BOOL WINAPI ctrl_handler(DWORD dwCtrlType) { return FALSE; } -#elseif __GNUC__ +#else +#ifdef __GNUG__ static sighandler_t set_signal_handler (int signum, sighandler_t signalhandler) { struct sigaction new_sig, old_sig; @@ -462,7 +463,8 @@ void ctrl_handler(int signum) { exit(1); } -#endif //TODO: __APPLE__ +#endif +#endif //TODO: __APPLE__ ? /********************************* * main - this is where it begins @@ -480,10 +482,12 @@ int main(int argc, char **argv) t_start = boost::posix_time::second_clock::universal_time(); running = true; -#ifdef __MINGW32__ +#ifdef __MINGW__ SetConsoleCtrlHandler(ctrl_handler, TRUE); -##elseif __GNUC__ +#else +#ifdef __GNUG__ set_signal_handler(SIGINT, ctrl_handler); +#endif #endif //TODO: __APPLE__ if (argc < 2)