When API shuts down cgminer don't kill itself
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
diff --git a/api.c b/api.c
index 0e0db5b..40c9353 100644
--- a/api.c
+++ b/api.c
@@ -349,6 +349,7 @@ struct CODES {
{ SEVERITY_FAIL, 0, 0, NULL }
};
+static int my_thr_id = 0;
static int bye = 0;
static bool ping = true;
@@ -1135,6 +1136,9 @@ void doquit(SOCKETTYPE c, __maybe_unused char *param, bool isjson)
send_result(c, isjson);
*io_buffer = '\0';
bye = 1;
+
+ PTH(&thr_info[my_thr_id]) = 0L;
+
kill_work();
}
@@ -1347,7 +1351,7 @@ popipo:
free(buf);
}
-void api(void)
+void api(int api_thr_id)
{
char buf[BUFSIZ];
char param_buf[BUFSIZ];
@@ -1372,6 +1376,8 @@ void api(void)
bool did;
int i;
+ my_thr_id = api_thr_id;
+
/* This should be done first to ensure curl has already called WSAStartup() in windows */
sleep(opt_log_interval);
diff --git a/cgminer.c b/cgminer.c
index 0e2d449..38e4239 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2802,7 +2802,7 @@ static void *api_thread(void *userdata)
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- api();
+ api(api_thr_id);
PTH(mythr) = 0L;
diff --git a/miner.h b/miner.h
index c383f91..c2b0ace 100644
--- a/miner.h
+++ b/miner.h
@@ -449,7 +449,7 @@ extern int set_engineclock(int gpu, int iEngineClock);
extern int set_memoryclock(int gpu, int iMemoryClock);
#endif
-extern void api(void);
+extern void api(int thr_id);
#define MAX_GPUDEVICES 16
#define MAX_DEVICES 32