Browse Source

ckdb - allow setting workmarkers as processed via marks command

master
kanoi 10 years ago
parent
commit
3ae5e9d2b7
  1. 2
      src/ckdb.h
  2. 37
      src/ckdb_cmd.c
  3. 4
      src/ckdb_dbio.c

2
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "0.9.6"
#define CKDB_VERSION DB_VERSION"-0.830"
#define CKDB_VERSION DB_VERSION"-0.831"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__

37
src/ckdb_cmd.c

@ -4105,13 +4105,13 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
char msg[1024] = "";
K_ITEM *i_action, *i_workinfoid, *i_marktype, *i_description;
K_ITEM *i_height, *i_status, *i_extra, *m_item, *b_item, *w_item;
K_ITEM *wm_item, *wm_item_prev;
K_ITEM *wm_item, *wm_item_prev, *i_markerid;
WORKMARKERS *workmarkers;
K_TREE_CTX ctx[1];
BLOCKS *blocks;
MARKS *marks;
char *action;
int64_t workinfoid = -1;
int64_t workinfoid = -1, markerid = -1;
char *marktype;
int32_t height = 0;
char description[TXT_BIG+1] = { '\0' };
@ -4401,6 +4401,39 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
LOGERR("%s.%s", id, reply);
return strdup(reply);
}
} else if (strcasecmp(action, "processed") == 0) {
/* Mark a workmarker as processed
* Requires markerid */
i_markerid = require_name(trf_root, "markerid", 1, (char *)intpatt, reply, siz);
if (!i_markerid)
return strdup(reply);
TXT_TO_BIGINT("markerid", transfer_data(i_markerid), markerid);
K_RLOCK(workmarkers_free);
wm_item = find_workmarkerid(markerid, true, '\0');
K_RUNLOCK(workmarkers_free);
if (!wm_item) {
snprintf(reply, siz,
"unknown workmarkers with markerid %"PRId64, markerid);
return strdup(reply);
}
DATA_WORKMARKERS(workmarkers, wm_item);
if (WMPROCESSED(workmarkers->status)) {
snprintf(reply, siz,
"already processed markerid %"PRId64, markerid);
return strdup(reply);
}
ok = workmarkers_process(NULL, false, true, markerid,
workmarkers->poolinstance,
workmarkers->workinfoidend,
workmarkers->workinfoidstart,
workmarkers->description,
MARKER_PROCESSED_STR,
by, code, inet, cd, trf_root);
if (!ok) {
snprintf(reply, siz, "%s failed", action);
LOGERR("%s.%s", id, reply);
return strdup(reply);
}
} else {
snprintf(reply, siz, "unknown action '%s'", action);
LOGERR("%s.%s", id, reply);

4
src/ckdb_dbio.c

@ -5756,7 +5756,9 @@ bool markersummary_fill(PGconn *conn)
return ok;
}
/* Add means create a new one and expire the old one if it exists,
/* Already means there is a transaction already in progress
* so don't begin or commit/rollback
* Add means create a new one and expire the old one if it exists,
* otherwise we only expire the old one if it exists
* Add requires all db fields except markerid, however if markerid
* is non-zero, it will be used instead of getting a new one

Loading…
Cancel
Save