From e70ca1f89f6e802b3c1aa80f24ec7ea1abeff66c Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 1 Sep 2016 19:57:46 +1000 Subject: [PATCH] ckdb - add an ioqueue cmd_query and force flush the console ioqueue on exit --- src/ckdb.c | 8 ++++---- src/ckdb.h | 6 +++++- src/ckdb_cmd.c | 12 ++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index b290ea60..227d9604 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -436,9 +436,9 @@ int64_t mismatch_all_marks; int64_t mismatch_all_total; // IOQUEUE -static K_LIST *ioqueue_free; -static K_STORE *ioqueue_store; -static K_STORE *console_ioqueue_store; +K_LIST *ioqueue_free; +K_STORE *ioqueue_store; +K_STORE *console_ioqueue_store; // Trigger ioqueue_store processing static mutex_t f_ioqueue_waitlock; static pthread_cond_t f_ioqueue_waitcond; @@ -1026,7 +1026,7 @@ static void *iomsgs(void *consol) } if (consol) { - if (!ioqueue_flush) { + if (!ioqueue_flush && !everyone_die) { // max 50 per second cksleep_ms(20); } diff --git a/src/ckdb.h b/src/ckdb.h index a66576e0..0ccc0180 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -58,7 +58,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.443" +#define CKDB_VERSION DB_VERSION"-2.444" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -1117,6 +1117,10 @@ typedef struct ioqueue { #define INIT_IOQUEUE(_item) INIT_GENERIC(_item, ioqueue) #define DATA_IOQUEUE(_var, _item) DATA_GENERIC(_var, _item, ioqueue, true) +extern K_LIST *ioqueue_free; +extern K_STORE *ioqueue_store; +extern K_STORE *console_ioqueue_store; + // LOGQUEUE typedef struct logqueue { char *msg; diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 18413aa8..e49d628a 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -7637,6 +7637,18 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, "NameRAM", FLDSEP, "", FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + ok = true; + } else if (strcasecmp(request, "ioqueue") == 0) { + K_RLOCK(ioqueue_free); + snprintf(tmp, sizeof(tmp), "console=%d%c", + console_ioqueue_store->count, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "file=%d%c", + ioqueue_store->count, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + K_RUNLOCK(ioqueue_free); + rows++; + ok = true; } else { free(buf);