Browse Source

ckdb - dealloc_storage optional memory deallocation to speed up shutdown

master
kanoi 9 years ago
parent
commit
09bac4ece8
  1. 35
      src/ckdb.c
  2. 14
      src/ckdb.h

35
src/ckdb.c

@ -128,6 +128,8 @@ static char *restorefrom;
bool genpayout_auto;
bool markersummary_auto;
enum free_modes free_mode = FREE_MODE_FAST;
int switch_state = SWITCH_STATE_ALL;
// disallow: '/' WORKSEP1 WORKSEP2 and FLDSEP
@ -1277,6 +1279,11 @@ static void dealloc_storage()
SHARES *shares;
int seq;
if (free_mode == FREE_MODE_NONE) {
LOGWARNING("%s() skipped", __func__);
return;
}
LOGWARNING("%s() logqueue ...", __func__);
FREE_LISTS(logqueue);
@ -1292,6 +1299,9 @@ static void dealloc_storage()
FREE_STORE_DATA(workmarkers);
FREE_LIST_DATA(workmarkers);
if (free_mode != FREE_MODE_ALL)
LOGWARNING("%s() markersummary skipped", __func__);
else {
LOGWARNING("%s() markersummary ...", __func__);
FREE_TREE(markersummary_pool);
@ -1301,6 +1311,7 @@ static void dealloc_storage()
FREE_TREE(markersummary);
FREE_STORE_DATA(markersummary);
FREE_LIST_DATA(markersummary);
}
FREE_ALL(workerstatus);
@ -1376,12 +1387,16 @@ static void dealloc_storage()
FREE_STORE(shares_early);
FREE_ALL(shares);
if (free_mode != FREE_MODE_ALL)
LOGWARNING("%s() workinfo skipped", __func__);
else {
LOGWARNING("%s() workinfo ...", __func__);
FREE_TREE(workinfo_height);
FREE_TREE(workinfo);
FREE_STORE_DATA(workinfo);
FREE_LIST_DATA(workinfo);
}
FREE_LISTS(idcontrol);
FREE_ALL(accountbalance);
@ -1409,6 +1424,9 @@ static void dealloc_storage()
FREE_LISTS(workqueue);
FREE_LISTS(msgline);
if (free_mode != FREE_MODE_ALL)
LOGWARNING("%s() seqset skipped", __func__);
else {
LOGWARNING("%s() seqset ...", __func__);
sequence_report(false);
@ -1421,6 +1439,7 @@ static void dealloc_storage()
for (seq = 0; seq < SEQ_MAX; seq++)
FREENULL(seqnam[seq]);
}
LOGWARNING("%s() finished", __func__);
}
@ -5501,6 +5520,7 @@ static void check_restore_dir(char *name)
static struct option long_options[] = {
{ "config", required_argument, 0, 'c' },
{ "dbname", required_argument, 0, 'd' },
{ "free", required_argument, 0, 'f' },
// generate = enable payout pplns auto generation
{ "generate", no_argument, 0, 'g' },
{ "help", no_argument, 0, 'h' },
@ -5563,6 +5583,21 @@ int main(int argc, char **argv)
while (*kill)
*(kill++) = ' ';
break;
case 'f':
if (strcasecmp(optarg, FREE_MODE_ALL_STR) == 0)
free_mode = FREE_MODE_ALL;
else if (strcasecmp(optarg, FREE_MODE_NONE_STR) == 0)
free_mode = FREE_MODE_NONE;
else if (strcasecmp(optarg, FREE_MODE_FAST_STR) == 0)
free_mode = FREE_MODE_FAST;
else {
quit(1, "Invalid free '%s' must be: "
FREE_MODE_ALL_STR", "
FREE_MODE_NONE_STR" or "
FREE_MODE_FAST_STR,
optarg);
}
break;
case 'g':
genpayout_auto = true;
break;

14
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "1.0.4"
#define CKDB_VERSION DB_VERSION"-1.503"
#define CKDB_VERSION DB_VERSION"-1.504"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -98,6 +98,18 @@ extern int switch_state;
extern bool genpayout_auto;
extern bool markersummary_auto;
enum free_modes {
FREE_MODE_ALL,
FREE_MODE_NONE,
FREE_MODE_FAST
};
#define FREE_MODE_ALL_STR "all"
#define FREE_MODE_NONE_STR "none"
#define FREE_MODE_FAST_STR "fast"
extern enum free_modes free_mode;
#define BLANK " "
extern char *EMPTY;

Loading…
Cancel
Save