|
|
@ -150,10 +150,10 @@ |
|
|
|
* and a warning is displayed if there were any matching shares |
|
|
|
* and a warning is displayed if there were any matching shares |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
bool socketer_release; |
|
|
|
static bool socketer_using_data; |
|
|
|
bool summariser_release; |
|
|
|
static bool summariser_using_data; |
|
|
|
bool logger_release; |
|
|
|
static bool logger_using_data; |
|
|
|
bool listener_release; |
|
|
|
static bool listener_using_data; |
|
|
|
|
|
|
|
|
|
|
|
char *EMPTY = ""; |
|
|
|
char *EMPTY = ""; |
|
|
|
|
|
|
|
|
|
|
@ -1024,6 +1024,16 @@ static void free_sharesummary_data(K_ITEM *item) |
|
|
|
SET_MODIFYINET(sharesummary_free, sharesummary->modifyinet, EMPTY); |
|
|
|
SET_MODIFYINET(sharesummary_free, sharesummary->modifyinet, EMPTY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void free_optioncontrol_data(K_ITEM *item) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
OPTIONCONTROL *optioncontrol; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DATA_OPTIONCONTROL(optioncontrol, item); |
|
|
|
|
|
|
|
if (optioncontrol->optionvalue) |
|
|
|
|
|
|
|
free(optioncontrol->optionvalue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define FREE_TREE(_tree) \ |
|
|
|
#define FREE_TREE(_tree) \ |
|
|
|
if (_tree ## _root) \
|
|
|
|
if (_tree ## _root) \
|
|
|
|
_tree ## _root = free_ktree(_tree ## _root, NULL) \
|
|
|
|
_tree ## _root = free_ktree(_tree ## _root, NULL) \
|
|
|
@ -1104,7 +1114,25 @@ static void dealloc_storage() |
|
|
|
FREE_ALL(payments); |
|
|
|
FREE_ALL(payments); |
|
|
|
FREE_ALL(paymentaddresses); |
|
|
|
FREE_ALL(paymentaddresses); |
|
|
|
FREE_ALL(workers); |
|
|
|
FREE_ALL(workers); |
|
|
|
FREE_ALL(optioncontrol); |
|
|
|
|
|
|
|
|
|
|
|
FREE_TREE(optioncontrol); |
|
|
|
|
|
|
|
if (optioncontrol_store) { |
|
|
|
|
|
|
|
item = optioncontrol_store->head; |
|
|
|
|
|
|
|
while (item) { |
|
|
|
|
|
|
|
free_optioncontrol_data(item); |
|
|
|
|
|
|
|
item = item->next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
FREE_STORE(optioncontrol); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (optioncontrol_free) { |
|
|
|
|
|
|
|
item = optioncontrol_free->head; |
|
|
|
|
|
|
|
while (item) { |
|
|
|
|
|
|
|
free_optioncontrol_data(item); |
|
|
|
|
|
|
|
item = item->next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
FREE_LIST(optioncontrol); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FREE_ALL(useratts); |
|
|
|
FREE_ALL(useratts); |
|
|
|
|
|
|
|
|
|
|
|
FREE_TREE(userid); |
|
|
|
FREE_TREE(userid); |
|
|
@ -1774,6 +1802,8 @@ static void *summariser(__maybe_unused void *arg) |
|
|
|
while (!everyone_die && !db_load_complete) |
|
|
|
while (!everyone_die && !db_load_complete) |
|
|
|
cksleep_ms(42); |
|
|
|
cksleep_ms(42); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
summariser_using_data = true; |
|
|
|
|
|
|
|
|
|
|
|
while (!everyone_die) { |
|
|
|
while (!everyone_die) { |
|
|
|
for (i = 0; i < 5; i++) { |
|
|
|
for (i = 0; i < 5; i++) { |
|
|
|
if (!everyone_die) |
|
|
|
if (!everyone_die) |
|
|
@ -1807,7 +1837,7 @@ static void *summariser(__maybe_unused void *arg) |
|
|
|
summarise_userstats(); |
|
|
|
summarise_userstats(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
summariser_release = true; |
|
|
|
summariser_using_data = false; |
|
|
|
|
|
|
|
|
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
@ -1824,6 +1854,8 @@ static void *logger(__maybe_unused void *arg) |
|
|
|
snprintf(buf, sizeof(buf), "db%s_logger", dbcode); |
|
|
|
snprintf(buf, sizeof(buf), "db%s_logger", dbcode); |
|
|
|
rename_proc(buf); |
|
|
|
rename_proc(buf); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger_using_data = true; |
|
|
|
|
|
|
|
|
|
|
|
setnow(&now); |
|
|
|
setnow(&now); |
|
|
|
snprintf(buf, sizeof(buf), "logstart.%ld,%ld", |
|
|
|
snprintf(buf, sizeof(buf), "logstart.%ld,%ld", |
|
|
|
now.tv_sec, now.tv_usec); |
|
|
|
now.tv_sec, now.tv_usec); |
|
|
@ -1866,7 +1898,7 @@ static void *logger(__maybe_unused void *arg) |
|
|
|
} |
|
|
|
} |
|
|
|
K_WUNLOCK(logqueue_free); |
|
|
|
K_WUNLOCK(logqueue_free); |
|
|
|
|
|
|
|
|
|
|
|
logger_release = true; |
|
|
|
logger_using_data = false; |
|
|
|
|
|
|
|
|
|
|
|
setnow(&now); |
|
|
|
setnow(&now); |
|
|
|
snprintf(buf, sizeof(buf), "logstop.%ld,%ld", |
|
|
|
snprintf(buf, sizeof(buf), "logstop.%ld,%ld", |
|
|
@ -1923,6 +1955,8 @@ static void *socketer(__maybe_unused void *arg) |
|
|
|
while (!everyone_die && !db_auths_complete) |
|
|
|
while (!everyone_die && !db_auths_complete) |
|
|
|
cksem_mswait(&socketer_sem, 420); |
|
|
|
cksem_mswait(&socketer_sem, 420); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socketer_using_data = true; |
|
|
|
|
|
|
|
|
|
|
|
want_first = true; |
|
|
|
want_first = true; |
|
|
|
while (!everyone_die) { |
|
|
|
while (!everyone_die) { |
|
|
|
if (buf) |
|
|
|
if (buf) |
|
|
@ -2272,7 +2306,7 @@ static void *socketer(__maybe_unused void *arg) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
socketer_release = true; |
|
|
|
socketer_using_data = false; |
|
|
|
|
|
|
|
|
|
|
|
if (buf) |
|
|
|
if (buf) |
|
|
|
dealloc(buf); |
|
|
|
dealloc(buf); |
|
|
@ -2620,6 +2654,8 @@ static void *listener(void *arg) |
|
|
|
|
|
|
|
|
|
|
|
rename_proc("db_listener"); |
|
|
|
rename_proc("db_listener"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listener_using_data = true; |
|
|
|
|
|
|
|
|
|
|
|
if (!setup_data()) { |
|
|
|
if (!setup_data()) { |
|
|
|
if (!everyone_die) { |
|
|
|
if (!everyone_die) { |
|
|
|
LOGEMERG("ABORTING"); |
|
|
|
LOGEMERG("ABORTING"); |
|
|
@ -2675,7 +2711,7 @@ static void *listener(void *arg) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listener_release = true; |
|
|
|
listener_using_data = false; |
|
|
|
|
|
|
|
|
|
|
|
if (conn) |
|
|
|
if (conn) |
|
|
|
PQfinish(conn); |
|
|
|
PQfinish(conn); |
|
|
@ -3474,7 +3510,6 @@ int main(int argc, char **argv) |
|
|
|
// TODO: add a system lock to stop running 2 at once?
|
|
|
|
// TODO: add a system lock to stop running 2 at once?
|
|
|
|
confirm_summaries(); |
|
|
|
confirm_summaries(); |
|
|
|
everyone_die = true; |
|
|
|
everyone_die = true; |
|
|
|
socketer_release = summariser_release = listener_release = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ckp.main.sockname = strdup("listener"); |
|
|
|
ckp.main.sockname = strdup("listener"); |
|
|
|
write_namepid(&ckp.main); |
|
|
|
write_namepid(&ckp.main); |
|
|
@ -3496,8 +3531,8 @@ int main(int argc, char **argv) |
|
|
|
char *msg = NULL; |
|
|
|
char *msg = NULL; |
|
|
|
|
|
|
|
|
|
|
|
trigger = start = time(NULL); |
|
|
|
trigger = start = time(NULL); |
|
|
|
while (!socketer_release || !summariser_release || |
|
|
|
while (socketer_using_data || summariser_using_data || |
|
|
|
!logger_release || !listener_release) { |
|
|
|
logger_using_data || listener_using_data) { |
|
|
|
msg = NULL; |
|
|
|
msg = NULL; |
|
|
|
curr = time(NULL); |
|
|
|
curr = time(NULL); |
|
|
|
if (curr - start > 4) { |
|
|
|
if (curr - start > 4) { |
|
|
@ -3511,10 +3546,10 @@ int main(int argc, char **argv) |
|
|
|
trigger = curr; |
|
|
|
trigger = curr; |
|
|
|
printf("%s %ds due to%s%s%s%s\n", |
|
|
|
printf("%s %ds due to%s%s%s%s\n", |
|
|
|
msg, (int)(curr - start), |
|
|
|
msg, (int)(curr - start), |
|
|
|
socketer_release ? EMPTY : " socketer", |
|
|
|
socketer_using_data ? " socketer" : EMPTY, |
|
|
|
summariser_release ? EMPTY : " summariser", |
|
|
|
summariser_using_data ? " summariser" : EMPTY, |
|
|
|
logger_release ? EMPTY : " logger", |
|
|
|
logger_using_data ? " logger" : EMPTY, |
|
|
|
listener_release ? EMPTY : " listener"); |
|
|
|
listener_using_data ? " listener" : EMPTY); |
|
|
|
fflush(stdout); |
|
|
|
fflush(stdout); |
|
|
|
} |
|
|
|
} |
|
|
|
sleep(1); |
|
|
|
sleep(1); |
|
|
|