|
@@ -305,7 +305,7 @@ static int include_count;
|
|
|
|
|
|
|
|
bool ping = true;
|
|
bool ping = true;
|
|
|
|
|
|
|
|
-struct sigaction termhandler, inthandler, segvhandler, bushandler, illhandler;
|
|
|
|
|
|
|
+struct sigaction termhandler, inthandler;
|
|
|
|
|
|
|
|
struct thread_q *getq;
|
|
struct thread_q *getq;
|
|
|
|
|
|
|
@@ -1229,7 +1229,7 @@ static struct opt_table opt_config_table[] = {
|
|
|
"Do not automatically disable pools that continually reject shares"),
|
|
"Do not automatically disable pools that continually reject shares"),
|
|
|
OPT_WITHOUT_ARG("--no-restart",
|
|
OPT_WITHOUT_ARG("--no-restart",
|
|
|
opt_set_invbool, &opt_restart,
|
|
opt_set_invbool, &opt_restart,
|
|
|
- "Do not attempt to restart devices that hang or BFGMiner if it crashes"
|
|
|
|
|
|
|
+ "Do not attempt to restart devices that hang"
|
|
|
),
|
|
),
|
|
|
OPT_WITHOUT_ARG("--no-stratum",
|
|
OPT_WITHOUT_ARG("--no-stratum",
|
|
|
opt_set_invbool, &want_stratum,
|
|
opt_set_invbool, &want_stratum,
|
|
@@ -3093,8 +3093,13 @@ char **initial_args;
|
|
|
|
|
|
|
|
static void clean_up(void);
|
|
static void clean_up(void);
|
|
|
|
|
|
|
|
-static inline void __app_restart(void)
|
|
|
|
|
|
|
+void app_restart(void)
|
|
|
{
|
|
{
|
|
|
|
|
+ applog(LOG_WARNING, "Attempting to restart %s", packagename);
|
|
|
|
|
+
|
|
|
|
|
+ __kill_work();
|
|
|
|
|
+ clean_up();
|
|
|
|
|
+
|
|
|
#if defined(unix)
|
|
#if defined(unix)
|
|
|
if (forkpid > 0) {
|
|
if (forkpid > 0) {
|
|
|
kill(forkpid, SIGTERM);
|
|
kill(forkpid, SIGTERM);
|
|
@@ -3103,55 +3108,17 @@ static inline void __app_restart(void)
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
execv(initial_args[0], initial_args);
|
|
execv(initial_args[0], initial_args);
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void app_restart(void)
|
|
|
|
|
-{
|
|
|
|
|
- applog(LOG_WARNING, "Attempting to restart %s", packagename);
|
|
|
|
|
-
|
|
|
|
|
- __kill_work();
|
|
|
|
|
- clean_up();
|
|
|
|
|
-
|
|
|
|
|
- __app_restart();
|
|
|
|
|
-
|
|
|
|
|
- /* We shouldn't reach here */
|
|
|
|
|
applog(LOG_WARNING, "Failed to restart application");
|
|
applog(LOG_WARNING, "Failed to restart application");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* Returns all signal handlers to their defaults */
|
|
|
|
|
-static inline void __sighandler(void)
|
|
|
|
|
|
|
+static void sighandler(int __maybe_unused sig)
|
|
|
{
|
|
{
|
|
|
/* Restore signal handlers so we can still quit if kill_work fails */
|
|
/* Restore signal handlers so we can still quit if kill_work fails */
|
|
|
sigaction(SIGTERM, &termhandler, NULL);
|
|
sigaction(SIGTERM, &termhandler, NULL);
|
|
|
sigaction(SIGINT, &inthandler, NULL);
|
|
sigaction(SIGINT, &inthandler, NULL);
|
|
|
- if (opt_restart) {
|
|
|
|
|
- sigaction(SIGSEGV, &segvhandler, NULL);
|
|
|
|
|
- sigaction(SIGILL, &illhandler, NULL);
|
|
|
|
|
-#ifndef WIN32
|
|
|
|
|
- sigaction(SIGBUS, &bushandler, NULL);
|
|
|
|
|
-#endif
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static void sighandler(int __maybe_unused sig)
|
|
|
|
|
-{
|
|
|
|
|
- __sighandler();
|
|
|
|
|
kill_work();
|
|
kill_work();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* Handles segfaults and other crashes by attempting to restart cgminer. Try to
|
|
|
|
|
- * do as little as possible since we are probably corrupted. */
|
|
|
|
|
-static void seghandler(int sig)
|
|
|
|
|
-{
|
|
|
|
|
- __sighandler();
|
|
|
|
|
- fprintf(stderr, "\nCrashed with signal %d! Will attempt to restart\n", sig);
|
|
|
|
|
- __app_restart();
|
|
|
|
|
- /* We shouldn't reach here */
|
|
|
|
|
- fprintf(stderr, "Failed to restart, exiting now\n");
|
|
|
|
|
-
|
|
|
|
|
- exit(1);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static void start_longpoll(void);
|
|
static void start_longpoll(void);
|
|
|
static void stop_longpoll(void);
|
|
static void stop_longpoll(void);
|
|
|
|
|
|
|
@@ -7582,18 +7549,6 @@ int main(int argc, char *argv[])
|
|
|
if (!config_loaded)
|
|
if (!config_loaded)
|
|
|
load_default_config();
|
|
load_default_config();
|
|
|
|
|
|
|
|
- if (opt_restart) {
|
|
|
|
|
- struct sigaction shandler;
|
|
|
|
|
-
|
|
|
|
|
- shandler.sa_handler = &seghandler;
|
|
|
|
|
- shandler.sa_flags = 0;
|
|
|
|
|
- sigemptyset(&shandler.sa_mask);
|
|
|
|
|
- sigaction(SIGSEGV, &shandler, &segvhandler);
|
|
|
|
|
- sigaction(SIGILL, &shandler, &illhandler);
|
|
|
|
|
-#ifndef WIN32
|
|
|
|
|
- sigaction(SIGBUS, &shandler, &bushandler);
|
|
|
|
|
-#endif
|
|
|
|
|
- }
|
|
|
|
|
if (opt_benchmark) {
|
|
if (opt_benchmark) {
|
|
|
struct pool *pool;
|
|
struct pool *pool;
|
|
|
|
|
|