From 468e9ee8d70c44eecfe71058cd3ec194523be10e Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 16 Jan 2015 18:31:55 +1100 Subject: [PATCH] ckdb - add a flush socket command to flush stdin, stdout and the logmsg log file --- src/ckdb.c | 12 ++++++++++++ src/ckdb.h | 3 ++- src/ckdb_cmd.c | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ckdb.c b/src/ckdb.c index 3b9858a2..71b22bea 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -2720,6 +2720,17 @@ static void *socketer(__maybe_unused void *arg) } send_unix_msg(sockd, reply); break; + case CMD_FLUSH: + LOGDEBUG("Listener received flush request"); + snprintf(reply, sizeof(reply), + "%s.%ld.ok.splash", + id, now.tv_sec); + send_unix_msg(sockd, reply); + fflush(stdout); + fflush(stderr); + if (global_ckp && global_ckp->logfd) + fflush(global_ckp->logfp); + break; // Always process immediately: case CMD_AUTH: case CMD_ADDRAUTH: @@ -2996,6 +3007,7 @@ static bool reload_line(PGconn *conn, char *filename, uint64_t count, char *buf) case CMD_PING: case CMD_VERSION: case CMD_LOGLEVEL: + case CMD_FLUSH: // Non pool commands, shouldn't be there case CMD_ADDUSER: case CMD_NEWPASS: diff --git a/src/ckdb.h b/src/ckdb.h index 4de78164..40da3ffa 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.6" -#define CKDB_VERSION DB_VERSION"-0.834" +#define CKDB_VERSION DB_VERSION"-0.835" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -290,6 +290,7 @@ enum cmd_values { CMD_PING, CMD_VERSION, CMD_LOGLEVEL, + CMD_FLUSH, CMD_SHARELOG, CMD_AUTH, CMD_ADDRAUTH, diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 5ece47c8..37fbd179 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -4525,6 +4525,7 @@ struct CMDS ckdb_cmds[] = { { CMD_PING, "ping", true, false, NULL, ACCESS_SYSTEM ACCESS_POOL ACCESS_WEB }, { CMD_VERSION, "version", true, false, NULL, ACCESS_SYSTEM ACCESS_POOL ACCESS_WEB }, { CMD_LOGLEVEL, "loglevel", true, false, NULL, ACCESS_SYSTEM }, + { CMD_FLUSH, "flush", true, false, NULL, ACCESS_SYSTEM }, { CMD_SHARELOG, STR_WORKINFO, false, true, cmd_sharelog, ACCESS_POOL }, { CMD_SHARELOG, STR_SHARES, false, true, cmd_sharelog, ACCESS_POOL }, { CMD_SHARELOG, STR_SHAREERRORS, false, true, cmd_sharelog, ACCESS_POOL },