Browse Source

ckdb - shift wasn't flagging workers used if not in the last shift

master
kanoi 9 years ago
parent
commit
8b8eb5dc62
  1. 2
      src/ckdb.h
  2. 30
      src/ckdb_cmd.c
  3. 6
      src/ckdb_crypt.c

2
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.2" #define DB_VERSION "1.0.2"
#define CKDB_VERSION DB_VERSION"-1.301" #define CKDB_VERSION DB_VERSION"-1.302"
#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__

30
src/ckdb_cmd.c

@ -269,6 +269,7 @@ static char *cmd_2fa(__maybe_unused PGconn *conn, char *cmd, char *id,
__func__, __func__,
st = safe_text_nonull(users->username), st = safe_text_nonull(users->username),
users->databits); users->databits);
FREENULL(st);
goto dame; goto dame;
} }
@ -5073,6 +5074,7 @@ typedef struct worker_match {
bool match; bool match;
size_t len; size_t len;
bool used; bool used;
bool everused;
} WM; } WM;
static char *worker_offset(char *workername) static char *worker_offset(char *workername)
@ -5158,7 +5160,7 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id,
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
char *select = NULL; char *select = NULL;
WM workm[SELECT_LIMIT+1]; WM workm[SELECT_LIMIT+1];
char *buf, *work; char *buf = NULL, *work, *st = NULL;
size_t len, off; size_t len, off;
tv_t marker_end = { 0L, 0L }; tv_t marker_end = { 0L, 0L };
int rows, want, i, where_all; int rows, want, i, where_all;
@ -5198,12 +5200,19 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id,
if (i_select) if (i_select)
select = strdup(transfer_data(i_select)); select = strdup(transfer_data(i_select));
APPEND_REALLOC_INIT(buf, off, len);
snprintf(tmp, sizeof(tmp), " select='%s'",
select ? st = safe_text_nonull(select) : "null");
FREENULL(st);
APPEND_REALLOC(buf, off, len, tmp);
bzero(workm, sizeof(workm)); bzero(workm, sizeof(workm));
where_all = select_list(&(workm[0]), select); where_all = select_list(&(workm[0]), select);
// Nothing selected = all // Nothing selected = all
if (workm[0].worker == NULL) { if (workm[0].worker == NULL) {
where_all = 0; where_all = 0;
workm[0].worker = WORKERS_ALL; workm[0].worker = WORKERS_ALL;
APPEND_REALLOC(buf, off, len, " no workers");
} else { } else {
for (i = 0; workm[i].worker; i++) { for (i = 0; workm[i].worker; i++) {
// N.B. len is only used if match is true // N.B. len is only used if match is true
@ -5214,12 +5223,24 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id,
workm[i].match = true; workm[i].match = true;
workm[i].len--; workm[i].len--;
} }
snprintf(tmp, sizeof(tmp), " workm[%d]=%s,%s,%d",
i, st = safe_text_nonull(workm[i].worker),
workm[i].match ? "Y" : "N",
(int)(workm[i].len));
FREENULL(st);
APPEND_REALLOC(buf, off, len, tmp);
} }
} }
if (where_all >= 0) if (where_all >= 0)
workm[where_all].used = true; workm[where_all].used = true;
snprintf(tmp, sizeof(tmp), " where_all=%d", where_all);
APPEND_REALLOC(buf, off, len, tmp);
LOGDEBUG("%s() user=%"PRId64"/%s' %s",
__func__, users->userid, users->username, buf+1);
FREENULL(buf);
APPEND_REALLOC_INIT(buf, off, len); APPEND_REALLOC_INIT(buf, off, len);
APPEND_REALLOC(buf, off, len, "ok."); APPEND_REALLOC(buf, off, len, "ok.");
INIT_MARKERSUMMARY(&ms_look); INIT_MARKERSUMMARY(&ms_look);
@ -5269,6 +5290,7 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id,
(workm[want].match && strncmp(work, workm[want].worker, workm[want].len) == 0) || (workm[want].match && strncmp(work, workm[want].worker, workm[want].len) == 0) ||
(!(workm[want].match) && strcmp(workm[want].worker, work) == 0)) { (!(workm[want].match) && strcmp(workm[want].worker, work) == 0)) {
workm[want].used = true; workm[want].used = true;
workm[want].everused = true;
ms_add[want].diffacc += ms->diffacc; ms_add[want].diffacc += ms->diffacc;
ms_add[want].diffsta += ms->diffsta; ms_add[want].diffsta += ms->diffsta;
ms_add[want].diffdup += ms->diffdup; ms_add[want].diffdup += ms->diffdup;
@ -5414,7 +5436,7 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id,
K_RUNLOCK(workmarkers_free); K_RUNLOCK(workmarkers_free);
for (i = 0; workm[i].worker; i++) { for (i = 0; workm[i].worker; i++) {
if (workm[i].used) { if (workm[i].everused) {
snprintf(tmp, sizeof(tmp), snprintf(tmp, sizeof(tmp),
"%d_worker=%s%s%c", "%d_worker=%s%s%c",
i, workm[i].worker, i, workm[i].worker,
@ -5448,7 +5470,7 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id,
snprintf(tmp, sizeof(tmp), "arn=%s", "Shifts"); snprintf(tmp, sizeof(tmp), "arn=%s", "Shifts");
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
for (i = 0; workm[i].worker; i++) { for (i = 0; workm[i].worker; i++) {
if (workm[i].used) { if (workm[i].everused) {
snprintf(tmp, sizeof(tmp), ",Worker_%d", i); snprintf(tmp, sizeof(tmp), ",Worker_%d", i);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
} }
@ -5457,7 +5479,7 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id,
snprintf(tmp, sizeof(tmp), "%carp=", FLDSEP); snprintf(tmp, sizeof(tmp), "%carp=", FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
for (i = 0; workm[i].worker; i++) { for (i = 0; workm[i].worker; i++) {
if (workm[i].used) { if (workm[i].everused) {
snprintf(tmp, sizeof(tmp), ",%d_", i); snprintf(tmp, sizeof(tmp), ",%d_", i);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
} }

6
src/ckdb_crypt.c

@ -36,7 +36,7 @@ char *_tob32(USERS *users, unsigned char *bin, size_t len, char *name,
if (osiz != olen) { if (osiz != olen) {
LOGEMERG("%s() of '%s' data for '%s' invalid olen=%d != osiz=%d" LOGEMERG("%s() of '%s' data for '%s' invalid olen=%d != osiz=%d"
WHERE_FFL, WHERE_FFL,
__func__, name, safe_text_nonull(users->username), __func__, name, st = safe_text_nonull(users->username),
(int)olen, (int)osiz, WHERE_FFL_PASS); (int)olen, (int)osiz, WHERE_FFL_PASS);
FREENULL(st); FREENULL(st);
olen = osiz; olen = osiz;
@ -59,8 +59,8 @@ char *_tob32(USERS *users, unsigned char *bin, size_t len, char *name,
"ch=%d, i=%d j=%d bits=%d bin=0x%s len=%d " "ch=%d, i=%d j=%d bits=%d bin=0x%s len=%d "
"olen=%d" WHERE_FFL, "olen=%d" WHERE_FFL,
__func__, name, __func__, name,
safe_text_nonull(users->username), ch, i, j, st = safe_text_nonull(users->username),
bits, binstr, (int)len, (int)olen, ch, i, j, bits, binstr, (int)len, (int)olen,
WHERE_FFL_PASS); WHERE_FFL_PASS);
FREENULL(st); FREENULL(st);
FREENULL(binstr); FREENULL(binstr);

Loading…
Cancel
Save