Browse Source

ckdb - use intransients for 'code' in MSGLINE and SEQENTRY

master
kanoi 8 years ago
parent
commit
2eaf18fc33
  1. 46
      src/ckdb.c
  2. 10
      src/ckdb.h

46
src/ckdb.c

@ -485,6 +485,8 @@ char *intransient_fields[] = {
NULL NULL
}; };
INTRANSIENT *in_empty;
// MSGLINE // MSGLINE
K_LIST *msgline_free; K_LIST *msgline_free;
K_STORE *msgline_store; K_STORE *msgline_store;
@ -2282,7 +2284,8 @@ static void alloc_storage()
check_deadlocks = true; check_deadlocks = true;
#endif #endif
// set intransient // setup intransients
in_empty = get_intransient("empty", EMPTY);
auth_1.intransient = get_intransient(auth_1.name, ""); auth_1.intransient = get_intransient(auth_1.name, "");
auth_1.mvalue = auth_1.intransient->str; auth_1.mvalue = auth_1.intransient->str;
userstats_workername = get_intransient("workername", "all"); userstats_workername = get_intransient("workername", "all");
@ -3152,7 +3155,7 @@ static void msgs_seq(SEQFOUND *found_msgs)
* sequence code */ * sequence code */
static bool update_seq(enum seq_num seq, uint64_t n_seqcmd, static bool update_seq(enum seq_num seq, uint64_t n_seqcmd,
uint64_t n_seqstt, uint64_t n_seqpid, uint64_t n_seqstt, uint64_t n_seqpid,
char *nam, tv_t *now, tv_t *cd, char *code, char *nam, tv_t *now, tv_t *cd, INTRANSIENT *in_code,
int seqentryflags, char *msg) int seqentryflags, char *msg)
{ {
static SEQFOUND found[SEQ_MAX]; static SEQFOUND found[SEQ_MAX];
@ -3178,7 +3181,7 @@ static bool update_seq(enum seq_num seq, uint64_t n_seqcmd,
LOGDEBUG("%s() SQ %c:%d/%s/%"PRIu64"/%"PRIu64"/%"PRIu64"/%s '%.80s...", LOGDEBUG("%s() SQ %c:%d/%s/%"PRIu64"/%"PRIu64"/%"PRIu64"/%s '%.80s...",
__func__, SECHR(seqentryflags), seq, nam, n_seqcmd, n_seqstt, __func__, SECHR(seqentryflags), seq, nam, n_seqcmd, n_seqstt,
n_seqpid, code, st = safe_text(msg)); n_seqpid, in_code->str, st = safe_text(msg));
FREENULL(st); FREENULL(st);
firstseq = newseq = expseq = gothigh = okhi = gotstale = firstseq = newseq = expseq = gothigh = okhi = gotstale =
@ -3579,7 +3582,7 @@ setitemdata:
seqentry->flags = seqentryflags; seqentry->flags = seqentryflags;
copy_tv(&(seqentry->time), now); copy_tv(&(seqentry->time), now);
copy_tv(&(seqentry->cd), cd); copy_tv(&(seqentry->cd), cd);
STRNCPY(seqentry->code, code); seqentry->in_code = in_code->str;
seqdata->ok++; seqdata->ok++;
seqset->ok++; seqset->ok++;
} }
@ -3643,7 +3646,7 @@ setitemdata:
(level == LOG_DEBUG) ? "*" : EMPTY, (level == LOG_DEBUG) ? "*" : EMPTY,
SECHR(seqentryflags), SECHR(seqentry_copy.flags), SECHR(seqentryflags), SECHR(seqentry_copy.flags),
nam, n_seqcmd, set, n_seqstt, t_buf, n_seqpid, nam, n_seqcmd, set, n_seqstt, t_buf, n_seqpid,
t_buf2, code, t_buf2, in_code->str,
seqset_copy.seqdata[seq].minseq, seqset_copy.seqdata[seq].minseq,
seqset_copy.seqdata[seq].maxseq, seqset_copy.seqdata[seq].maxseq,
seqset_copy.seqdata[seq].missing, seqset_copy.seqdata[seq].missing,
@ -3742,7 +3745,7 @@ setitemdata:
LOGWARNING("SEQ recovered %s %"PRIu64" set:%d/%"PRIu64 LOGWARNING("SEQ recovered %s %"PRIu64" set:%d/%"PRIu64
"=%s/%"PRIu64" %s/%s", "=%s/%"PRIu64" %s/%s",
nam, n_seqcmd, set, n_seqstt, t_buf, n_seqpid, nam, n_seqcmd, set, n_seqstt, t_buf, n_seqpid,
t_buf2, code); t_buf2, in_code->str);
} }
if (gotstale || gotstalestart || gothigh) { if (gotstale || gotstalestart || gothigh) {
@ -3755,7 +3758,7 @@ setitemdata:
gothigh ? (okhi ? "OKHI" : "HIGH") : "stale", gothigh ? (okhi ? "OKHI" : "HIGH") : "stale",
gotstalestart ? "STARTUP " : EMPTY, gotstalestart ? "STARTUP " : EMPTY,
nam, n_seqcmd, set, n_seqstt, t_buf, n_seqpid, nam, n_seqcmd, set, n_seqstt, t_buf, n_seqpid,
t_buf2, code, t_buf2, in_code->str,
seqset_copy.seqdata[seq].minseq, seqset_copy.seqdata[seq].minseq,
seqset_copy.seqdata[seq].maxseq, seqset_copy.seqdata[seq].maxseq,
seqset_copy.seqdata[seq].missing, seqset_copy.seqdata[seq].missing,
@ -3827,7 +3830,7 @@ setitemdata:
seqnam[seq], range_buf, set, seqnam[seq], range_buf, set,
n_seqstt, t_buf, n_seqpid, n_seqstt, t_buf, n_seqpid,
isrange ? "last: " : EMPTY, isrange ? "last: " : EMPTY,
t_buf2, seqtrans->entry.code); t_buf2, seqtrans->entry.in_code);
} }
K_WLOCK(seqtrans_free); K_WLOCK(seqtrans_free);
k_list_transfer_to_head(lost, seqtrans_free); k_list_transfer_to_head(lost, seqtrans_free);
@ -3874,13 +3877,13 @@ static enum cmd_values process_seq(MSGLINE *msgline)
dupall = update_seq(SEQ_ALL, msgline->n_seqall, dupall = update_seq(SEQ_ALL, msgline->n_seqall,
msgline->n_seqstt, msgline->n_seqpid, msgline->n_seqstt, msgline->n_seqpid,
SEQALL, &(msgline->now), &(msgline->cd), SEQALL, &(msgline->now), &(msgline->cd),
msgline->code, msgline->seqentryflags, msgline->in_code, msgline->seqentryflags,
msgline->msg); msgline->msg);
} }
dupcmd = update_seq(ckdb_cmds[msgline->which_cmds].seq, dupcmd = update_seq(ckdb_cmds[msgline->which_cmds].seq,
msgline->n_seqcmd, msgline->n_seqstt, msgline->n_seqcmd, msgline->n_seqstt,
msgline->n_seqpid, msgline->seqcmdnam, msgline->n_seqpid, msgline->seqcmdnam,
&(msgline->now), &(msgline->cd), msgline->code, &(msgline->now), &(msgline->cd), msgline->in_code,
msgline->seqentryflags, msgline->msg); msgline->seqentryflags, msgline->msg);
if (ignore_seqall) if (ignore_seqall)
@ -3914,9 +3917,11 @@ static enum cmd_values process_seq(MSGLINE *msgline)
static void setup_seq(K_ITEM *seqall, MSGLINE *msgline) static void setup_seq(K_ITEM *seqall, MSGLINE *msgline)
{ {
K_ITEM *seqstt, *seqpid, *seqcmd, *i_code; K_ITEM *seqstt, *seqpid, *seqcmd;
char *err = NULL, *st = NULL; char *err = NULL, *st = NULL;
size_t len, off; size_t len, off;
char reply[16] = "";
size_t siz = sizeof(reply);
msgline->n_seqall = atol(transfer_data(seqall)); msgline->n_seqall = atol(transfer_data(seqall));
if ((seqstt = find_transfer(msgline->trf_root, SEQSTT))) if ((seqstt = find_transfer(msgline->trf_root, SEQSTT)))
@ -3985,16 +3990,13 @@ static void setup_seq(K_ITEM *seqall, MSGLINE *msgline)
msgline->hasseq = true; msgline->hasseq = true;
if ((i_code = find_transfer(msgline->trf_root, CODETRF))) { msgline->in_code = optional_in(msgline->trf_root, CODETRF, 1, NULL,
msgline->code = transfer_data(i_code); reply, siz);
if (!(*(msgline->code))) if (!(msgline->in_code)) {
msgline->code = NULL; msgline->in_code = optional_in(msgline->trf_root, BYTRF,
} 0, NULL, reply, siz);
if (!(msgline->code)) { if (!msgline->in_code)
if ((i_code = find_transfer(msgline->trf_root, BYTRF))) msgline->in_code = in_empty;
msgline->code = transfer_data(i_code);
else
msgline->code = EMPTY;
} }
} }
@ -4058,7 +4060,7 @@ static enum cmd_values breakdown(K_ITEM **ml_item, char *buf, tv_t *now,
* you can ignore the access failed items by skipping items * you can ignore the access failed items by skipping items
* that start with a capital, since all (currently) are lower case * that start with a capital, since all (currently) are lower case
* however, command checks are case insensitive, so replaying * however, command checks are case insensitive, so replaying
* the file will allow these commands, if they are present */ * the file will try these commands, if they are present */
if ((ckdb_cmds[msgline->which_cmds].access & access) == 0) if ((ckdb_cmds[msgline->which_cmds].access & access) == 0)
buf[0] = toupper(buf[0]); buf[0] = toupper(buf[0]);

10
src/ckdb.h

@ -58,7 +58,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.7" #define DB_VERSION "1.0.7"
#define CKDB_VERSION DB_VERSION"-2.504" #define CKDB_VERSION DB_VERSION"-2.505"
#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__
@ -1335,6 +1335,7 @@ extern K_LIST *intransient_free;
extern K_STORE *intransient_store; extern K_STORE *intransient_store;
extern char *intransient_fields[]; extern char *intransient_fields[];
extern INTRANSIENT *in_empty;
// MSGLINE // MSGLINE
typedef struct msgline { typedef struct msgline {
@ -1355,7 +1356,7 @@ typedef struct msgline {
uint64_t n_seqstt; uint64_t n_seqstt;
uint64_t n_seqpid; uint64_t n_seqpid;
int seqentryflags; int seqentryflags;
char *code; INTRANSIENT *in_code;
K_TREE *trf_root; K_TREE *trf_root;
K_STORE *trf_store; K_STORE *trf_store;
int sockd; int sockd;
@ -1680,9 +1681,6 @@ enum seq_num {
SEQ_MAX SEQ_MAX
}; };
// Ensure size is a (multiple of 8)-1
#define SEQ_CODE 15
#define SECHR(_sif) (((_sif) == SE_EARLYSOCK) ? 'E' : \ #define SECHR(_sif) (((_sif) == SE_EARLYSOCK) ? 'E' : \
(((_sif) == SE_RELOAD) ? 'R' : \ (((_sif) == SE_RELOAD) ? 'R' : \
(((_sif) == SE_SOCKET) ? 'S' : '?'))) (((_sif) == SE_SOCKET) ? 'S' : '?')))
@ -1698,7 +1696,7 @@ typedef struct seqentry {
int flags; int flags;
tv_t cd; // sec:0=missing, usec:0=miss !0=trans tv_t cd; // sec:0=missing, usec:0=miss !0=trans
tv_t time; tv_t time;
char code[SEQ_CODE+1]; char *in_code;
} SEQENTRY; } SEQENTRY;
typedef struct seqdata { typedef struct seqdata {

Loading…
Cancel
Save