Browse Source

Merge branch 'master' into multiproxy

Conflicts:
	src/stratifier.c
master
Con Kolivas 10 years ago
parent
commit
0b5e34f08b
  1. 2
      src/ckdb.h
  2. 41
      src/ckdb_dbio.c
  3. 20
      src/stratifier.c

2
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "1.0.0"
#define CKDB_VERSION DB_VERSION"-1.033"
#define CKDB_VERSION DB_VERSION"-1.035"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__

41
src/ckdb_dbio.c

@ -3313,6 +3313,11 @@ flail:
return ok;
}
/* Keep some simple stats on how often shares are out of order
* and how often they produce a WARNING due to OOOLIMIT */
static int64_t ooof0, ooof, oool0, oool;
#define OOOLIMIT -2.0
bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row, K_ITEM *ss_item,
char *by, char *code, char *inet, tv_t *cd, WHERE_FFL_ARGS)
{
@ -3438,13 +3443,25 @@ bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row, K_ITE
if (!new) {
double td;
td = tvdiff(sharecreatedate, &(row->firstshare));
// don't LOGERR '=' in case shares come from ckpool with the same timestamp
// don't LOG '=' in case shares come from ckpool with the same timestamp
if (td < 0.0) {
char *tmp1, *tmp2;
LOGERR("%s(): %s createdate (%s) is < summary firstshare (%s)",
int level;
// DEBUG only for shares out of order up to OOOLIMIT seconds
if (td < OOOLIMIT) {
level = LOG_WARNING;
ooof++;
} else {
level = LOG_DEBUG;
ooof0++;
}
LOGMSG(level, "%s(): OoO %s createdate (%s) is < summary"
" firstshare (%s) (F%"PRId64":%"PRId64
"/L%"PRId64":%"PRId64"/%.1f)",
__func__, s_row ? "shares" : "shareerrors",
(tmp1 = ctv_to_buf(sharecreatedate, NULL, 0)),
(tmp2 = ctv_to_buf(&(row->firstshare), NULL, 0)));
(tmp2 = ctv_to_buf(&(row->firstshare), NULL, 0)),
ooof, ooof0, oool, oool0, OOOLIMIT);
free(tmp2);
free(tmp1);
row->firstshare.tv_sec = sharecreatedate->tv_sec;
@ -3452,17 +3469,29 @@ bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row, K_ITE
// Don't change lastdiffacc
}
td = tvdiff(sharecreatedate, &(row->lastshare));
// don't LOGERR '=' in case shares come from ckpool with the same timestamp
// don't LOG '=' in case shares come from ckpool with the same timestamp
if (td >= 0.0) {
row->lastshare.tv_sec = sharecreatedate->tv_sec;
row->lastshare.tv_usec = sharecreatedate->tv_usec;
row->lastdiffacc = diff;
} else {
char *tmp1, *tmp2;
LOGERR("%s(): %s createdate (%s) is < summary lastshare (%s)",
int level;
// DEBUG only for shares out of order up to OOOLIMIT seconds
if (td < OOOLIMIT) {
level = LOG_WARNING;
oool++;
} else {
level = LOG_DEBUG;
oool0++;
}
LOGMSG(level, "%s(): OoO %s createdate (%s) is < summary"
" lastshare (%s) (F%"PRId64":%"PRId64
"/L%"PRId64":%"PRId64"/%.1f)",
__func__, s_row ? "shares" : "shareerrors",
(tmp1 = ctv_to_buf(sharecreatedate, NULL, 0)),
(tmp2 = ctv_to_buf(&(row->lastshare), NULL, 0)));
(tmp2 = ctv_to_buf(&(row->lastshare), NULL, 0)),
ooof, ooof0, oool, oool0, OOOLIMIT);
free(tmp2);
free(tmp1);
}

20
src/stratifier.c

@ -1050,14 +1050,15 @@ static void __disconnect_session(sdata_t *sdata, const stratum_instance_t *clien
/* Removes a client instance we know is on the stratum_instances list and from
* the user client list if it's been placed on it */
static void __del_client(sdata_t *sdata, stratum_instance_t *client, user_instance_t *user)
static void __del_client(sdata_t *sdata, stratum_instance_t *client)
{
user_instance_t *user = client->user_instance;
HASH_DEL(sdata->stratum_instances, client);
if (user) {
DL_DELETE(user->clients, client);
__dec_worker(sdata, user);
}
}
static void connector_drop_client(ckpool_t *ckp, const int64_t id)
@ -1080,7 +1081,7 @@ static void drop_allclients(ckpool_t *ckp)
int64_t client_id = client->id;
if (!client->ref) {
__del_client(sdata, client, client->user_instance);
__del_client(sdata, client);
__kill_instance(sdata, client);
} else
client->dropped = true;
@ -1884,11 +1885,10 @@ static stratum_instance_t *ref_instance_by_id(sdata_t *sdata, const int64_t id)
return client;
}
static void __drop_client(sdata_t *sdata, stratum_instance_t *client, user_instance_t *user,
bool lazily, char **msg)
static void __drop_client(sdata_t *sdata, stratum_instance_t *client, bool lazily, char **msg)
{
user_instance_t *user = client->user_instance;
__del_client(sdata, client, user);
if (client->workername) {
if (user) {
ASPRINTF(msg, "Client %"PRId64" %s %suser %s worker %s dropped %s",
@ -1903,6 +1903,7 @@ static void __drop_client(sdata_t *sdata, stratum_instance_t *client, user_insta
ASPRINTF(msg, "Workerless client %"PRId64" %s dropped %s",
client->id, client->address, lazily ? "lazily" : "");
}
__del_client(sdata, client);
__kill_instance(sdata, client);
}
@ -1910,7 +1911,6 @@ static void __drop_client(sdata_t *sdata, stratum_instance_t *client, user_insta
static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const char *file,
const char *func, const int line)
{
user_instance_t *user = client->user_instance;
char_entry_t *entries = NULL;
bool dropped = false;
char *msg;
@ -1922,7 +1922,7 @@ static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const
* moved due to holding a reference and drop them now. */
if (unlikely(client->dropped && !ref)) {
dropped = true;
__drop_client(sdata, client, user, true, &msg);
__drop_client(sdata, client, true, &msg);
add_msg_entry(&entries, &msg);
}
ck_wunlock(&sdata->instance_lock);
@ -2105,7 +2105,6 @@ static void stratum_add_send(sdata_t *sdata, json_t *val, const int64_t client_i
static void drop_client(ckpool_t *ckp, sdata_t *sdata, const int64_t id)
{
char_entry_t *entries = NULL;
user_instance_t *user = NULL;
stratum_instance_t *client;
char *msg;
@ -2115,11 +2114,10 @@ static void drop_client(ckpool_t *ckp, sdata_t *sdata, const int64_t id)
client = __instance_by_id(sdata, id);
if (client && !client->dropped) {
__disconnect_session(sdata, client);
user = client->user_instance;
/* If the client is still holding a reference, don't drop them
* now but wait till the reference is dropped */
if (!client->ref) {
__drop_client(sdata, client, user, false, &msg);
__drop_client(sdata, client, false, &msg);
add_msg_entry(&entries, &msg);
} else
client->dropped = true;

Loading…
Cancel
Save