Browse Source

Merge branch 'master' of bitbucket.org:ckolivas/ckpool

master
Con Kolivas 9 years ago
parent
commit
0d588462aa
  1. 11
      src/ckdb.c
  2. 2
      src/ckdb.h
  3. 39
      src/ckdb_cmd.c
  4. 2
      src/klist.h

11
src/ckdb.c

@ -1746,7 +1746,7 @@ static void trans_process(SEQSET *seqset, tv_t *now, K_STORE *store)
seqtrans->seq = seq; seqtrans->seq = seq;
seqtrans->seqnum = u; seqtrans->seqnum = u;
memcpy(&(seqtrans->entry), seqentry, sizeof(SEQENTRY)); memcpy(&(seqtrans->entry), seqentry, sizeof(SEQENTRY));
k_add_head(store, st_item); k_add_head_nolock(store, st_item);
} }
u++; u++;
seqentry++; seqentry++;
@ -1772,7 +1772,7 @@ static void trans_process(SEQSET *seqset, tv_t *now, K_STORE *store)
seqtrans->seq = seq; seqtrans->seq = seq;
seqtrans->seqnum = u; seqtrans->seqnum = u;
memcpy(&(seqtrans->entry), seqentry, sizeof(SEQENTRY)); memcpy(&(seqtrans->entry), seqentry, sizeof(SEQENTRY));
k_add_head(store, st_item); k_add_head_nolock(store, st_item);
} }
u++; u++;
seqentry++; seqentry++;
@ -2143,7 +2143,7 @@ gotseqset:
sizeof(SEQENTRY)); sizeof(SEQENTRY));
if (!lost) if (!lost)
lost = k_new_store(seqtrans_free); lost = k_new_store(seqtrans_free);
k_add_tail(lost, st_item); k_add_tail_nolock(lost, st_item);
seqdata->lost++; seqdata->lost++;
seqset->lost++; seqset->lost++;
if (ENTRYISTRANS(u_entry)) { if (ENTRYISTRANS(u_entry)) {
@ -2173,7 +2173,7 @@ gotseqset:
seqdata->reload_lost = k_new_store(seqtrans_free); seqdata->reload_lost = k_new_store(seqtrans_free);
seqdata_reload_lost = true; seqdata_reload_lost = true;
} }
k_add_tail(seqdata->reload_lost, stl_item); k_add_tail_nolock(seqdata->reload_lost, stl_item);
} }
} else { } else {
// (u-size) wasn't missing // (u-size) wasn't missing
@ -2254,8 +2254,7 @@ gotseqset:
} }
if (st_item) { if (st_item) {
// recovered a lost entry // recovered a lost entry
k_unlink_item(seqtrans_free, st_item); k_unlink_item_nolock(seqdata->reload_lost, st_item);
// N.B. lock inside lock
K_WLOCK(seqtrans_free); K_WLOCK(seqtrans_free);
k_add_head(seqtrans_free, st_item); k_add_head(seqtrans_free, st_item);
K_WUNLOCK(seqtrans_free); K_WUNLOCK(seqtrans_free);

2
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.4" #define DB_VERSION "1.0.4"
#define CKDB_VERSION DB_VERSION"-1.610" #define CKDB_VERSION DB_VERSION"-1.612"
#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__

39
src/ckdb_cmd.c

@ -3636,9 +3636,9 @@ static char *cmd_setatts(PGconn *conn, char *cmd, char *id,
} }
} }
if (!ua_item) { if (!ua_item) {
K_RLOCK(useratts_free); K_WLOCK(useratts_free);
ua_item = k_unlink_head(useratts_free); ua_item = k_unlink_head(useratts_free);
K_RUNLOCK(useratts_free); K_WUNLOCK(useratts_free);
DATA_USERATTS(useratts, ua_item); DATA_USERATTS(useratts, ua_item);
bzero(useratts, sizeof(*useratts)); bzero(useratts, sizeof(*useratts));
useratts->userid = users->userid; useratts->userid = users->userid;
@ -5796,7 +5796,7 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
char description[TXT_BIG+1] = { '\0' }; char description[TXT_BIG+1] = { '\0' };
char extra[TXT_BIG+1] = { '\0' }; char extra[TXT_BIG+1] = { '\0' };
char status[TXT_FLAG+1] = { MARK_READY, '\0' }; char status[TXT_FLAG+1] = { MARK_READY, '\0' };
bool ok; bool ok = false, pps;
LOGDEBUG("%s(): cmd '%s'", __func__, cmd); LOGDEBUG("%s(): cmd '%s'", __func__, cmd);
@ -6237,6 +6237,39 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
old ? "On" : "Off", old ? "On" : "Off",
markersummary_auto ? "On" : "Off"); markersummary_auto ? "On" : "Off");
ok = true; ok = true;
} else if (strcasecmp(action, "pps") == 0) {
/* Recalculate a shift's rewards/rewarded
* Require 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, false, MARKER_PROCESSED);
K_RUNLOCK(workmarkers_free);
if (!wm_item) {
snprintf(reply, siz, "no markerid %"PRId64, markerid);
return strdup(reply);
}
DATA_WORKMARKERS(workmarkers, wm_item);
pps = shift_rewards(wm_item);
if (pps) {
snprintf(msg, sizeof(msg),
"shift '%s' markerid %"PRId64" rewards %d "
"rewarded %.3e pps %.3e",
workmarkers->description,
workmarkers->markerid, workmarkers->rewards,
workmarkers->rewarded, workmarkers->pps_value);
} else {
snprintf(msg, sizeof(msg),
"shift '%s' markerid %"PRId64" no rewards yet"
" pps %.3e",
workmarkers->description,
workmarkers->markerid, workmarkers->pps_value);
}
ok = true;
} else { } else {
snprintf(reply, siz, "unknown action '%s'", action); snprintf(reply, siz, "unknown action '%s'", action);
LOGERR("%s.%s", id, reply); LOGERR("%s.%s", id, reply);

2
src/klist.h

@ -586,7 +586,7 @@ extern void _k_insert_after(K_LIST *list, K_ITEM *item, K_ITEM *after, LOCK_MAYB
//#define k_insert_after_nolock(_list, _item, _after) _k_insert_after(_list, _item, _after, false, KLIST_FFL_HERE) //#define k_insert_after_nolock(_list, _item, _after) _k_insert_after(_list, _item, _after, false, KLIST_FFL_HERE)
extern void _k_unlink_item(K_LIST *list, K_ITEM *item, LOCK_MAYBE bool chklock, KLIST_FFL_ARGS); extern void _k_unlink_item(K_LIST *list, K_ITEM *item, LOCK_MAYBE bool chklock, KLIST_FFL_ARGS);
#define k_unlink_item(_list, _item) _k_unlink_item(_list, _item, true, KLIST_FFL_HERE) #define k_unlink_item(_list, _item) _k_unlink_item(_list, _item, true, KLIST_FFL_HERE)
//#define k_unlink_item_nolock(_list, _item) _k_unlink_item(_list, _item, false, KLIST_FFL_HERE) #define k_unlink_item_nolock(_list, _item) _k_unlink_item(_list, _item, false, KLIST_FFL_HERE)
extern void _k_list_transfer_to_head(K_LIST *from, K_LIST *to, LOCK_MAYBE bool chklock, KLIST_FFL_ARGS); extern void _k_list_transfer_to_head(K_LIST *from, K_LIST *to, LOCK_MAYBE bool chklock, KLIST_FFL_ARGS);
#define k_list_transfer_to_head(_from, _to) _k_list_transfer_to_head(_from, _to, true, KLIST_FFL_HERE) #define k_list_transfer_to_head(_from, _to) _k_list_transfer_to_head(_from, _to, true, KLIST_FFL_HERE)
//#define k_list_transfer_to_head_nolock(_from, _to) _k_list_transfer_to_head(_from, _to, false, KLIST_FFL_HERE) //#define k_list_transfer_to_head_nolock(_from, _to) _k_list_transfer_to_head(_from, _to, false, KLIST_FFL_HERE)

Loading…
Cancel
Save