From 19bce29d1c88ea428bc3004ef526438142026b26 Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 21 Apr 2015 15:31:24 +1000 Subject: [PATCH] ckdb - add a share status console report command shsta --- src/ckdb.c | 9 ++++++--- src/ckdb.h | 3 ++- src/ckdb_cmd.c | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 1b652518..197eda34 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -3674,10 +3674,10 @@ static void *socketer(__maybe_unused void *arg) case CMD_HEARTBEAT: // First message from the pool if (want_first) { + want_first = false; ck_wlock(&fpm_lock); first_pool_message = strdup(buf); ck_wunlock(&fpm_lock); - want_first = false; } case CMD_CHKPASS: case CMD_ADDUSER: @@ -3693,6 +3693,7 @@ static void *socketer(__maybe_unused void *arg) case CMD_NEWID: case CMD_STATS: case CMD_USERSTATUS: + case CMD_SHSTA: ans = ckdb_cmds[which_cmds].func(NULL, cmd, id, &now, by_default, (char *)__func__, @@ -3816,10 +3817,10 @@ static void *socketer(__maybe_unused void *arg) case CMD_BLOCK: // First message from the pool if (want_first) { + want_first = false; ck_wlock(&fpm_lock); first_pool_message = strdup(buf); ck_wunlock(&fpm_lock); - want_first = false; } snprintf(reply, sizeof(reply), @@ -3982,7 +3983,8 @@ static bool reload_line(PGconn *conn, char *filename, uint64_t count, char *buf) case CMD_USERSTATUS: case CMD_MARKS: case CMD_PSHIFT: - LOGERR("%s() Message line %"PRIu64" '%s' - invalid - ignored", + case CMD_SHSTA: + LOGERR("%s() INVALID message line %"PRIu64" '%s' - ignored", __func__, count, cmd); break; case CMD_AUTH: @@ -4348,6 +4350,7 @@ static void *listener(void *arg) K_RUNLOCK(workqueue_store); LOGWARNING("reload shares OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf))); + sequence_report(true); LOGWARNING("%s(): ckdb ready, queue %d", __func__, wqcount); diff --git a/src/ckdb.h b/src/ckdb.h index 30be9f8f..f7b8f43a 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.0" -#define CKDB_VERSION DB_VERSION"-1.074" +#define CKDB_VERSION DB_VERSION"-1.075" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -402,6 +402,7 @@ enum cmd_values { CMD_USERSTATUS, CMD_MARKS, CMD_PSHIFT, + CMD_SHSTA, CMD_END }; diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 6187d467..5e145ebd 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -5844,6 +5844,24 @@ static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id, return(buf); } +/* Show a share status report on the console + * Currently: sequence status and OoO info */ +static char *cmd_shsta(__maybe_unused PGconn *conn, char *cmd, char *id, + __maybe_unused tv_t *now, __maybe_unused char *by, + __maybe_unused char *code, __maybe_unused char *inet, + __maybe_unused tv_t *notcd, __maybe_unused K_TREE *trf_root) +{ + char ooo_buf[256]; + char buf[256]; + + LOGWARNING("OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf))); + sequence_report(true); + + snprintf(buf, sizeof(buf), "ok.%s", cmd); + LOGDEBUG("%s.%s", id, buf); + return strdup(buf); +} + // TODO: limit access by having seperate sockets for each #define ACCESS_POOL "p" #define ACCESS_SYSTEM "s" @@ -5955,5 +5973,6 @@ struct CMDS ckdb_cmds[] = { { CMD_USERSTATUS,"userstatus", false, false, cmd_userstatus, SEQ_NONE, ACCESS_SYSTEM ACCESS_WEB }, { CMD_MARKS, "marks", false, false, cmd_marks, SEQ_NONE, ACCESS_SYSTEM }, { CMD_PSHIFT, "pshift", false, false, cmd_pshift, SEQ_NONE, ACCESS_SYSTEM ACCESS_WEB }, + { CMD_SHSTA, "shsta", true, false, cmd_shsta, SEQ_NONE, ACCESS_SYSTEM }, { CMD_END, NULL, false, false, NULL, SEQ_NONE, NULL } };