Browse Source

RPC: Provide a full status section for quit/restart commands

Luke Dashjr 11 years ago
parent
commit
5833eed555
2 changed files with 8 additions and 20 deletions
  1. 4 4
      README.RPC
  2. 4 16
      api.c

+ 4 - 4
README.RPC

@@ -278,8 +278,8 @@ The list of requests - a (*) means it requires privileged access - and replies:
                               The filename is optional and will use the BFGMiner
                               The filename is optional and will use the BFGMiner
                               default if not specified
                               default if not specified
 
 
- quit (*)      none           There is no status section but just a single "BYE"
-                              reply before BFGMiner 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
  notify        NOTIFY         The last status and history count of each devices
                               problem
                               problem
@@ -336,8 +336,8 @@ The list of requests - a (*) means it requires privileged access - and replies:
                               supported by the 'devs' command
                               supported by the 'devs' command
                               e.g. DEVDETAILS=0,Name=BFL,ID=0,ProcID=0,Driver=bitforce,...|
                               e.g. DEVDETAILS=0,Name=BFL,ID=0,ProcID=0,Driver=bitforce,...|
 
 
- restart (*)   none           There is no status section but just a single
-                              "RESTART" reply before BFGMiner 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
  stats         STATS          Each device or pool that has 1 or more getworks
                               with a list of stats regarding getwork times
                               with a list of stats regarding getwork times

+ 4 - 16
api.c

@@ -169,8 +169,6 @@ static const char ISJSON = '{';
 #define JSON_CPUS	JSON1 _CPUS JSON2
 #define JSON_CPUS	JSON1 _CPUS JSON2
 #define JSON_NOTIFY	JSON1 _NOTIFY JSON2
 #define JSON_NOTIFY	JSON1 _NOTIFY JSON2
 #define JSON_DEVDETAILS	JSON1 _DEVDETAILS 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_CLOSE	JSON3
 #define JSON_MINESTATS	JSON1 _MINESTATS JSON2
 #define JSON_MINESTATS	JSON1 _MINESTATS JSON2
 #define JSON_CHECK	JSON1 _CHECK JSON2
 #define JSON_CHECK	JSON1 _CHECK JSON2
@@ -303,6 +301,7 @@ static const char *JSON_PARAMETER = "parameter";
 #define MSG_ZERNOSUM 97
 #define MSG_ZERNOSUM 97
 
 
 #define MSG_DEVSCAN 0x100
 #define MSG_DEVSCAN 0x100
+#define MSG_BYE 0x101
 
 
 #define MSG_INVNEG 121
 #define MSG_INVNEG 121
 #define MSG_SETQUOTA 122
 #define MSG_SETQUOTA 122
@@ -491,6 +490,7 @@ struct CODES {
  { SEVERITY_SUCC,  MSG_ZERSUM,	PARAM_STR,	"Zeroed %s stats with summary" },
  { SEVERITY_SUCC,  MSG_ZERSUM,	PARAM_STR,	"Zeroed %s stats with summary" },
  { SEVERITY_SUCC,  MSG_ZERNOSUM, PARAM_STR,	"Zeroed %s stats without summary" },
  { SEVERITY_SUCC,  MSG_ZERNOSUM, PARAM_STR,	"Zeroed %s stats without summary" },
  { SEVERITY_SUCC,  MSG_DEVSCAN, PARAM_COUNT,	"Added %d new device(s)" },
  { SEVERITY_SUCC,  MSG_DEVSCAN, PARAM_COUNT,	"Added %d new device(s)" },
+ { SEVERITY_SUCC,  MSG_BYE,		PARAM_STR,	"%s" },
  { SEVERITY_FAIL, 0, 0, NULL }
  { SEVERITY_FAIL, 0, 0, NULL }
 };
 };
 
 
@@ -620,12 +620,6 @@ static bool io_add(struct io_data *io_data, char *buf)
 	return true;
 	return true;
 }
 }
 
 
-static bool io_put(struct io_data *io_data, char *buf)
-{
-	bytes_reset(&io_data->data);
-	return io_add(io_data, buf);
-}
-
 static void io_close(struct io_data *io_data)
 static void io_close(struct io_data *io_data)
 {
 {
 	io_data->close = true;
 	io_data->close = true;
@@ -2796,10 +2790,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)
 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;
 	bye = true;
 	do_a_quit = true;
 	do_a_quit = true;
@@ -2807,10 +2798,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)
 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;
 	bye = true;
 	do_a_restart = true;
 	do_a_restart = true;