Browse Source

ckdb - setup the first mandatory mark on a new pool

master
kanoi 10 years ago
parent
commit
b32080e9a5
  1. 58
      src/ckdb.c
  2. 3
      src/ckdb.h

58
src/ckdb.c

@ -1885,6 +1885,64 @@ static void make_a_shift_mark()
char cd_buf[DATE_BUFSIZ], cd_buf2[DATE_BUFSIZ];
int used_wid;
/* If there are no CURRENT marks, make the first one by
* finding the first CURRENT workinfo and use that
* to create a MARKTYPE_OTHER_BEGIN for the pool
* This will keep being checked when the pool first starts
* until the first workinfo is created, but once the first
* marks has been created it will skip over the if code
* forever after that */
K_RLOCK(marks_free);
m_item = last_in_ktree(marks_root, m_ctx);
K_RUNLOCK(marks_free);
DATA_MARKS_NULL(marks, m_item);
// Mark sorting means all CURRENT will be on the end
if (!m_item || !CURRENT(&(marks->expirydate))) {
K_RLOCK(workinfo_free);
wi_item = first_in_ktree(workinfo_root, wi_ctx);
DATA_WORKINFO_NULL(workinfo, wi_item);
if (!wi_item) {
K_RUNLOCK(workinfo_free);
LOGWARNING("%s() ckdb workinfo:'%s' marks:'%s' ..."
" start ckpool!", __func__,
"none", m_item ? "expired" : "none");
return;
}
while (wi_item && !CURRENT(&(workinfo->expirydate))) {
wi_item = next_in_ktree(wi_ctx);
DATA_WORKINFO_NULL(workinfo, wi_item);
}
if (!wi_item) {
K_RUNLOCK(workinfo_free);
LOGWARNING("%s() ckdb workinfo:'%s' marks:'%s' ..."
" start ckpool!", __func__,
"expired", m_item ? "expired" : "none");
return;
}
K_RUNLOCK(workinfo_free);
char description[TXT_BIG+1];
tv_t now;
ok = marks_description(description, sizeof(description),
MARKTYPE_OTHER_BEGIN_STR, 0, NULL,
"Pool Start");
if (!ok)
return;
setnow(&now);
ok = marks_process(NULL, true, EMPTY, workinfo->workinfoid,
description, EMPTY, MARKTYPE_OTHER_BEGIN_STR,
MARK_USED_STR, (char *)by_default,
(char *)__func__, (char *)inet_default,
&now, NULL);
if (ok) {
LOGWARNING("%s() FIRST mark %"PRId64"/%s/%s/%s/",
__func__, workinfo->workinfoid,
MARKTYPE_OTHER_BEGIN_STR, MARK_USED_STR,
description);
}
return;
}
/* Find the last !new sharesummary workinfoid
* If the shift needs to go beyond this, then it's not ready yet */
ss_age_wid = 0;

3
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "1.0.0"
#define CKDB_VERSION DB_VERSION"-1.032"
#define CKDB_VERSION DB_VERSION"-1.033"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -1596,6 +1596,7 @@ extern K_STORE *marks_store;
#define MARKTYPE_SHIFT_END 'e'
// 'o' used for manual marks
#define MARKTYPE_OTHER_BEGIN 'o'
#define MARKTYPE_OTHER_BEGIN_STR "o"
// 'f' used for manual marks
#define MARKTYPE_OTHER_FINISH 'f'

Loading…
Cancel
Save