Browse Source

ckdb - add a field name for the get_intransient error message

master
kanoi 8 years ago
parent
commit
ee4f78bace
  1. 8
      src/ckdb.c
  2. 14
      src/ckdb.h
  3. 17
      src/ckdb_data.c

8
src/ckdb.c

@ -4181,7 +4181,9 @@ static enum cmd_values breakdown(K_ITEM **ml_item, char *buf, tv_t *now,
intrans = true; intrans = true;
// This will affect 'was' if JSON_END is missing // This will affect 'was' if JSON_END is missing
*(next + siz) = '\0'; *(next + siz) = '\0';
transfer->intransient = get_intransient_siz(next, siz+1); transfer->intransient =
get_intransient_siz(transfer->name,
next, siz+1);
transfer->mvalue = transfer->intransient->str; transfer->mvalue = transfer->intransient->str;
break; break;
} }
@ -4244,7 +4246,9 @@ static enum cmd_values breakdown(K_ITEM **ml_item, char *buf, tv_t *now,
if (strcmp(transfer->name, if (strcmp(transfer->name,
intransient_fields[i]) == 0) { intransient_fields[i]) == 0) {
intrans = true; intrans = true;
transfer->intransient = get_intransient_siz(eq, siz); transfer->intransient =
get_intransient_siz(transfer->name,
eq, siz);
transfer->mvalue = transfer->intransient->str; transfer->mvalue = transfer->intransient->str;
break; break;
} }

14
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.440" #define CKDB_VERSION DB_VERSION"-2.441"
#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__
@ -1153,7 +1153,7 @@ typedef struct intransient {
} INTRANSIENT; } INTRANSIENT;
/* Items never to be deleted and list never to be culled /* Items never to be deleted and list never to be culled
* They are all created by the db load functions and breakdown */ * They are all created by breakdown */
#define ALLOC_INTRANSIENT 1024 #define ALLOC_INTRANSIENT 1024
#define LIMIT_INTRANSIENT 0 #define LIMIT_INTRANSIENT 0
#define INIT_INTRANSIENT(_item) INIT_GENERIC(_item, intransient) #define INIT_INTRANSIENT(_item) INIT_GENERIC(_item, intransient)
@ -3111,10 +3111,12 @@ extern char *_hms_to_buf(time_t *data, char *buf, size_t siz, WHERE_FFL_ARGS);
extern char *_ms_to_buf(time_t *data, char *buf, size_t siz, WHERE_FFL_ARGS); extern char *_ms_to_buf(time_t *data, char *buf, size_t siz, WHERE_FFL_ARGS);
extern cmp_t cmp_intransient(K_ITEM *a, K_ITEM *b); extern cmp_t cmp_intransient(K_ITEM *a, K_ITEM *b);
#define get_intransient(_name) _get_intransient(_name, 0, WHERE_FFL_HERE) #define get_intransient(_fld, _val) \
#define get_intransient_siz(_name, _siz) \ _get_intransient(_fld, _val, 0, WHERE_FFL_HERE)
_get_intransient(_name, _siz, WHERE_FFL_HERE) #define get_intransient_siz(_fld, _val, _siz) \
extern INTRANSIENT *_get_intransient(char *name, size_t siz, WHERE_FFL_ARGS); _get_intransient(_fld, _val , _siz, WHERE_FFL_HERE)
extern INTRANSIENT *_get_intransient(char *fldnam, char *value, size_t siz,
WHERE_FFL_ARGS);
extern char *_transfer_data(K_ITEM *item, WHERE_FFL_ARGS); extern char *_transfer_data(K_ITEM *item, WHERE_FFL_ARGS);
extern void dsp_transfer(K_ITEM *item, FILE *stream); extern void dsp_transfer(K_ITEM *item, FILE *stream);
extern cmp_t cmp_transfer(K_ITEM *a, K_ITEM *b); extern cmp_t cmp_transfer(K_ITEM *a, K_ITEM *b);

17
src/ckdb_data.c

@ -715,7 +715,7 @@ cmp_t cmp_intransient(K_ITEM *a, K_ITEM *b)
return CMP_STR(ia->str, ib->str); return CMP_STR(ia->str, ib->str);
} }
INTRANSIENT *_get_intransient(char *name, size_t siz, WHERE_FFL_ARGS) INTRANSIENT *_get_intransient(char *fldnam, char *value, size_t siz, WHERE_FFL_ARGS)
{ {
INTRANSIENT intransient, *in = NULL; INTRANSIENT intransient, *in = NULL;
K_ITEM look, *i_item, *n_item; K_ITEM look, *i_item, *n_item;
@ -725,18 +725,19 @@ INTRANSIENT *_get_intransient(char *name, size_t siz, WHERE_FFL_ARGS)
bool new; bool new;
if (siz == 0) if (siz == 0)
siz = strlen(name) + 1; siz = strlen(value) + 1;
if (siz > sizeof(nameram->rem)) { if (siz > sizeof(nameram->rem)) {
char *st = NULL; char *st = NULL;
LOGEMERG("%s() ERR '%10s...' discarded - siz %d>%d" WHERE_FFL, LOGEMERG("%s() ERR %s='%10s...' discarded - siz %d>%d"
__func__, st = safe_text_nonull(name), (int)siz, WHERE_FFL,
(int)sizeof(nameram->rem), WHERE_FFL_PASS); __func__, fldnam, st = safe_text_nonull(value),
name = EMPTY; (int)siz, (int)sizeof(nameram->rem), WHERE_FFL_PASS);
value = EMPTY;
siz = 1; siz = 1;
} }
intransient.str = name; intransient.str = value;
INIT_INTRANSIENT(&look); INIT_INTRANSIENT(&look);
look.data = (void *)(&intransient); look.data = (void *)(&intransient);
K_RLOCK(intransient_free); K_RLOCK(intransient_free);
@ -779,7 +780,7 @@ INTRANSIENT *_get_intransient(char *name, size_t siz, WHERE_FFL_ARGS)
nameram->next += siz; nameram->next += siz;
nameram->left -= siz; nameram->left -= siz;
K_WUNLOCK(nameram_free); K_WUNLOCK(nameram_free);
strcpy(buf, name); strcpy(buf, value);
i_item = k_unlink_head(intransient_free); i_item = k_unlink_head(intransient_free);
DATA_INTRANSIENT(in, i_item); DATA_INTRANSIENT(in, i_item);
in->str = buf; in->str = buf;

Loading…
Cancel
Save