Browse Source

ckdb - separate valid and invalid last_share/last_share_inv

master
kanoi 10 years ago
parent
commit
23033b0ff1
  1. 2
      src/ckdb.c
  2. 3
      src/ckdb.h
  3. 8
      src/ckdb_cmd.c

2
src/ckdb.c

@ -279,6 +279,7 @@ bool everyone_die = false;
tv_t last_heartbeat;
tv_t last_workinfo;
tv_t last_share;
tv_t last_share_inv;
tv_t last_auth;
cklock_t last_lock;
@ -3250,6 +3251,7 @@ static void *listener(void *arg)
setnow(&last_heartbeat);
copy_tv(&last_workinfo, &last_heartbeat);
copy_tv(&last_share, &last_heartbeat);
copy_tv(&last_share_inv, &last_heartbeat);
copy_tv(&last_auth, &last_heartbeat);
ck_wunlock(&last_lock);

3
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "1.0.0"
#define CKDB_VERSION DB_VERSION"-1.008"
#define CKDB_VERSION DB_VERSION"-1.009"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -274,6 +274,7 @@ extern bool everyone_die;
extern tv_t last_heartbeat;
extern tv_t last_workinfo;
extern tv_t last_share;
extern tv_t last_share_inv;
extern tv_t last_auth;
extern cklock_t last_lock;

8
src/ckdb_cmd.c

@ -1954,8 +1954,13 @@ wiconf:
return strdup("failed.DATA");
} else {
// Only flag a successful share
int32_t errn;
TXT_TO_INT("errn", transfer_data(i_errn), errn);
ck_wlock(&last_lock);
if (errn == SE_NONE)
setnow(&last_share);
else
setnow(&last_share_inv);
ck_wunlock(&last_lock);
}
LOGDEBUG("%s.ok.added %s", id, transfer_data(i_nonce));
@ -2492,6 +2497,9 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id,
ftv_to_buf(&last_share, reply, siz);
snprintf(tmp, sizeof(tmp), "lastsh=%s%c", reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
ftv_to_buf(&last_share_inv, reply, siz);
snprintf(tmp, sizeof(tmp), "lastshinv=%s%c", reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
ftv_to_buf(&last_auth, reply, siz);
ck_wunlock(&last_lock);
snprintf(tmp, sizeof(tmp), "lastau=%s%c", reply, FLDSEP);

Loading…
Cancel
Save