From 3a6c1c8bb0414782cac57f601af9e6736c642f1b Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 25 Apr 2014 13:25:05 +0000 Subject: [PATCH 1/2] RPC: Provide a full status section for quit/restart commands --- api.c | 21 +++++---------------- doc/API | 8 ++++---- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/api.c b/api.c index 0bdfd9db..60097ba9 100644 --- a/api.c +++ b/api.c @@ -204,8 +204,6 @@ static const char ISJSON = '{'; #define JSON_GPUS JSON1 _GPUS JSON2 #define JSON_NOTIFY JSON1 _NOTIFY JSON2 #define JSON_DEVDETAILS JSON1 _DEVDETAILS JSON2 -#define JSON_BYE JSON1 _BYE JSON1 -#define JSON_RESTART JSON1 _RESTART JSON1 #define JSON_CLOSE JSON3 #define JSON_MINESTATS JSON1 _MINESTATS JSON2 #define JSON_CHECK JSON1 _CHECK JSON2 @@ -302,6 +300,8 @@ static const char *JSON_PARAMETER = "parameter"; #define MSG_ZERSUM 96 #define MSG_ZERNOSUM 97 +#define MSG_BYE 0x101 + #define MSG_INVNEG 121 #define MSG_SETQUOTA 122 #define MSG_LOCKOK 123 @@ -423,6 +423,7 @@ struct CODES { { SEVERITY_SUCC, MSG_ZERNOSUM, PARAM_STR, "Zeroed %s stats without summary" }, { SEVERITY_SUCC, MSG_LOCKOK, PARAM_NONE, "Lock stats created" }, { SEVERITY_WARN, MSG_LOCKDIS, PARAM_NONE, "Lock stats not enabled" }, + { SEVERITY_SUCC, MSG_BYE, PARAM_STR, "%s" }, { SEVERITY_FAIL, 0, (enum code_parameters)0, NULL } }; @@ -545,12 +546,6 @@ static bool io_add(struct io_data *io_data, char *buf) return true; } -static bool io_put(struct io_data *io_data, char *buf) -{ - io_reinit(io_data); - return io_add(io_data, buf); -} - static void io_close(struct io_data *io_data) { io_data->close = true; @@ -2576,10 +2571,7 @@ static void gpuvddc(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb void doquit(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group) { - if (isjson) - io_put(io_data, JSON_START JSON_BYE); - else - io_put(io_data, _BYE); + message(io_data, MSG_BYE, 0, _BYE, isjson); bye = true; do_a_quit = true; @@ -2587,10 +2579,7 @@ void doquit(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused void dorestart(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group) { - if (isjson) - io_put(io_data, JSON_START JSON_RESTART); - else - io_put(io_data, _RESTART); + message(io_data, MSG_BYE, 0, _RESTART, isjson); bye = true; do_a_restart = true; diff --git a/doc/API b/doc/API index ada9dd16..5bfe21a2 100644 --- a/doc/API +++ b/doc/API @@ -277,8 +277,8 @@ The list of requests - a (*) means it requires privileged access - and replies: The filename is optional and will use the sgminer default if not specified - quit (*) none There is no status section but just a single "BYE" - reply before sgminer quits + quit (*) none There is no reply section just the STATUS section + before BFGMiner quits notify NOTIFY The last status and history count of each devices problem @@ -328,8 +328,8 @@ The list of requests - a (*) means it requires privileged access - and replies: supported by the 'devs' command e.g. DEVDETAILS=0,Name=GPU,ID=0,Driver=opencl,...| - restart (*) none There is no status section but just a single - "RESTART" reply before sgminer restarts + restart (*) none There is no reply section just the STATUS section + before BFGMiner restarts stats STATS Each device or pool that has 1 or more getworks with a list of stats regarding getwork times From eb53e32d1685bc7fd8c55c541d31f8c0f9a30c07 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Fri, 25 Apr 2014 17:42:23 +0300 Subject: [PATCH 2/2] misc: add API restart/quit changes to NEWS.md. --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 4502204a..e11ba603 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * API response to `version` has field `CGMiner` instead of `SGMiner`, and an additional `Miner` field (by _luke-jr_). +* API response to `restart` and `quit` only contains a `status` section + and passes JSON validation (by _luke-jr_). ## Version 4.1.271 - 12th April 2014