Browse Source

ckdb - add a flush socket command to flush stdin, stdout and the logmsg log file

master
kanoi 10 years ago committed by Con Kolivas
parent
commit
69ec5e702c
  1. 12
      src/ckdb.c
  2. 3
      src/ckdb.h
  3. 1
      src/ckdb_cmd.c

12
src/ckdb.c

@ -2720,6 +2720,17 @@ static void *socketer(__maybe_unused void *arg)
} }
send_unix_msg(sockd, reply); send_unix_msg(sockd, reply);
break; 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: // Always process immediately:
case CMD_AUTH: case CMD_AUTH:
case CMD_ADDRAUTH: 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_PING:
case CMD_VERSION: case CMD_VERSION:
case CMD_LOGLEVEL: case CMD_LOGLEVEL:
case CMD_FLUSH:
// Non pool commands, shouldn't be there // Non pool commands, shouldn't be there
case CMD_ADDUSER: case CMD_ADDUSER:
case CMD_NEWPASS: case CMD_NEWPASS:

3
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "0.9.6" #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 " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -290,6 +290,7 @@ enum cmd_values {
CMD_PING, CMD_PING,
CMD_VERSION, CMD_VERSION,
CMD_LOGLEVEL, CMD_LOGLEVEL,
CMD_FLUSH,
CMD_SHARELOG, CMD_SHARELOG,
CMD_AUTH, CMD_AUTH,
CMD_ADDRAUTH, CMD_ADDRAUTH,

1
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_PING, "ping", true, false, NULL, ACCESS_SYSTEM ACCESS_POOL ACCESS_WEB },
{ CMD_VERSION, "version", 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_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_WORKINFO, false, true, cmd_sharelog, ACCESS_POOL },
{ CMD_SHARELOG, STR_SHARES, 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 }, { CMD_SHARELOG, STR_SHAREERRORS, false, true, cmd_sharelog, ACCESS_POOL },

Loading…
Cancel
Save