Browse Source

ckdb - add missing null checks in workinfo_age

master
kanoi 8 years ago
parent
commit
920070f07c
  1. 4
      src/ckdb.c
  2. 6
      src/ckdb.h
  3. 28
      src/ckdb_data.c

4
src/ckdb.c

@ -117,7 +117,7 @@ static bool blistener_using_data;
static bool breakdown_using_data; static bool breakdown_using_data;
static bool replier_using_data; static bool replier_using_data;
/* Flag to notify thread changes /* To notify thread changes
* Set/checked under the function's main loop's first lock * Set/checked under the function's main loop's first lock
* This is always a 'delta' value meaning add or subtract that many */ * This is always a 'delta' value meaning add or subtract that many */
int queue_threads_delta = 0; int queue_threads_delta = 0;
@ -131,7 +131,7 @@ static int reload_breakdown_threads = -1;
static int cmd_breakdown_threads = -1; static int cmd_breakdown_threads = -1;
// cpu count to breakdown thread ratio // cpu count to breakdown thread ratio
#define BREAKDOWN_RATIO 3 #define BREAKDOWN_RATIO 3
// Flags to notify thread changes // To notify thread changes
int reload_breakdown_threads_delta = 0; int reload_breakdown_threads_delta = 0;
int cmd_breakdown_threads_delta = 0; int cmd_breakdown_threads_delta = 0;

6
src/ckdb.h

@ -58,7 +58,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.7" #define DB_VERSION "1.0.7"
#define CKDB_VERSION DB_VERSION"-2.403" #define CKDB_VERSION DB_VERSION"-2.404"
#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__
@ -120,11 +120,11 @@ extern enum free_modes free_mode;
// Define the array size for thread data // Define the array size for thread data
#define THREAD_LIMIT 99 #define THREAD_LIMIT 99
/* Flag to notify thread changes /* To notify thread changes
* Set/checked under the function's main loop's first lock * Set/checked under the function's main loop's first lock
* This is always a 'delta' value meaning add or subtract that many */ * This is always a 'delta' value meaning add or subtract that many */
extern int queue_threads_delta; extern int queue_threads_delta;
/* Flags to notify thread changes */ // To notify thread changes
extern int reload_breakdown_threads_delta; extern int reload_breakdown_threads_delta;
extern int cmd_breakdown_threads_delta; extern int cmd_breakdown_threads_delta;

28
src/ckdb_data.c

@ -2288,9 +2288,11 @@ bool workinfo_age(int64_t workinfoid, char *poolinstance, tv_t *cd,
ss_look.data = (void *)(&looksharesummary); ss_look.data = (void *)(&looksharesummary);
K_RLOCK(sharesummary_free); K_RLOCK(sharesummary_free);
ss_item = find_after_in_ktree(sharesummary_workinfoid_root, &ss_look, ss_ctx); ss_item = find_after_in_ktree(sharesummary_workinfoid_root, &ss_look, ss_ctx);
DATA_SHARESUMMARY_NULL(sharesummary, ss_item); if (ss_item) {
// complete could change, the id fields wont be changed/removed yet DATA_SHARESUMMARY(sharesummary, ss_item);
STRNCPY(complete, sharesummary->complete); // complete could change, the id fields wont be changed/removed yet
STRNCPY(complete, sharesummary->complete);
}
K_RUNLOCK(sharesummary_free); K_RUNLOCK(sharesummary_free);
while (ss_item && sharesummary->workinfoid == workinfoid) { while (ss_item && sharesummary->workinfoid == workinfoid) {
ss_tot++; ss_tot++;
@ -2342,8 +2344,10 @@ bool workinfo_age(int64_t workinfoid, char *poolinstance, tv_t *cd,
K_RLOCK(sharesummary_free); K_RLOCK(sharesummary_free);
ss_item = next_in_ktree(ss_ctx); ss_item = next_in_ktree(ss_ctx);
DATA_SHARESUMMARY_NULL(sharesummary, ss_item); if (ss_item) {
STRNCPY(complete, sharesummary->complete); DATA_SHARESUMMARY(sharesummary, ss_item);
STRNCPY(complete, sharesummary->complete);
}
K_RUNLOCK(sharesummary_free); K_RUNLOCK(sharesummary_free);
} }
@ -2375,9 +2379,11 @@ skip_ss:
ks_look.data = (void *)(&lookkeysharesummary); ks_look.data = (void *)(&lookkeysharesummary);
K_RLOCK(keysharesummary_free); K_RLOCK(keysharesummary_free);
ks_item = find_after_in_ktree(keysharesummary_root, &ks_look, ks_ctx); ks_item = find_after_in_ktree(keysharesummary_root, &ks_look, ks_ctx);
DATA_KEYSHARESUMMARY_NULL(keysharesummary, ks_item); if (ks_item) {
// complete could change, the id fields wont be changed/removed yet DATA_KEYSHARESUMMARY(keysharesummary, ks_item);
STRNCPY(complete, keysharesummary->complete); // complete could change, the id fields wont be changed/removed yet
STRNCPY(complete, keysharesummary->complete);
}
K_RUNLOCK(keysharesummary_free); K_RUNLOCK(keysharesummary_free);
while (ks_item && keysharesummary->workinfoid == workinfoid) { while (ks_item && keysharesummary->workinfoid == workinfoid) {
ks_tot++; ks_tot++;
@ -2416,8 +2422,10 @@ skip_ss:
K_RLOCK(keysharesummary_free); K_RLOCK(keysharesummary_free);
ks_item = next_in_ktree(ks_ctx); ks_item = next_in_ktree(ks_ctx);
DATA_KEYSHARESUMMARY_NULL(keysharesummary, ks_item); if (ks_item) {
STRNCPY(complete, keysharesummary->complete); DATA_KEYSHARESUMMARY(keysharesummary, ks_item);
STRNCPY(complete, keysharesummary->complete);
}
K_RUNLOCK(keysharesummary_free); K_RUNLOCK(keysharesummary_free);
} }

Loading…
Cancel
Save