Browse Source

ckdb - add an ioqueue cmd_query and force flush the console ioqueue on exit

master
kanoi 8 years ago
parent
commit
e70ca1f89f
  1. 8
      src/ckdb.c
  2. 6
      src/ckdb.h
  3. 12
      src/ckdb_cmd.c

8
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);
}

6
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;

12
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);

Loading…
Cancel
Save