8
8
int uwsgi_calc_cheaper(void) {
12
static time_t last_check = 0;
13
int check_interval = uwsgi.shared->options[UWSGI_OPTION_MASTER_INTERVAL];
14
if (!last_check) last_check = time(NULL);
15
time_t now = time(NULL);
16
if (!check_interval) check_interval = 1;
17
if ( (now - last_check) < check_interval) return 1;
11
static time_t last_check = 0;
12
int check_interval = uwsgi.shared->options[UWSGI_OPTION_MASTER_INTERVAL];
14
if (!last_check) last_check = time(NULL);
16
time_t now = time(NULL);
20
if ( (now - last_check) < check_interval) return 1;
20
24
int needed_workers = uwsgi.cheaper_algo();
541
545
uc_month = ucron->month;
542
546
uc_week = ucron->week;
544
if (ucron->minute == -1)
545
uc_minute = uwsgi_cron_delta->tm_min;
546
if (ucron->hour == -1)
547
uc_hour = uwsgi_cron_delta->tm_hour;
548
if (ucron->month == -1)
549
uc_month = uwsgi_cron_delta->tm_mon;
550
if (ucron->day == -1)
551
uc_day = uwsgi_cron_delta->tm_mday;
552
if (ucron->week == -1)
553
uc_week = uwsgi_cron_delta->tm_wday;
548
// negative values as interval -1 = * , -5 = */5
549
if (ucron->minute < 0) {
550
if ((uwsgi_cron_delta->tm_min % abs(ucron->minute)) == 0) {
551
uc_minute = uwsgi_cron_delta->tm_min;
554
if (ucron->hour < 0) {
555
if ((uwsgi_cron_delta->tm_hour % abs(ucron->hour)) == 0) {
556
uc_hour = uwsgi_cron_delta->tm_hour;
559
if (ucron->month < 0) {
560
if ((uwsgi_cron_delta->tm_mon % abs(ucron->month)) == 0) {
561
uc_month = uwsgi_cron_delta->tm_mon;
564
if (ucron->day < 0) {
565
if ((uwsgi_cron_delta->tm_mday % abs(ucron->day)) == 0) {
566
uc_day = uwsgi_cron_delta->tm_mday;
569
if (ucron->week < 0) {
570
if ((uwsgi_cron_delta->tm_wday % abs(ucron->week)) == 0) {
571
uc_week = uwsgi_cron_delta->tm_wday;
555
575
int run_task = 0;
556
576
// mday and wday are ORed
557
if (ucron->day != -1 && ucron->week != -1) {
577
if (ucron->day >= 0 && ucron->week >= 0) {
558
578
if (uwsgi_cron_delta->tm_min == uc_minute && uwsgi_cron_delta->tm_hour == uc_hour && uwsgi_cron_delta->tm_mon == uc_month && (uwsgi_cron_delta->tm_mday == uc_day || uwsgi_cron_delta->tm_wday == uc_week)) {
622
uwsgi_cron_delta->tm_mon++;
601
624
while (current_cron) {
604
626
uc_minute = current_cron->minute;
605
627
uc_hour = current_cron->hour;
606
628
uc_day = current_cron->day;
607
629
uc_month = current_cron->month;
608
630
uc_week = current_cron->week;
610
if (current_cron->minute == -1)
611
uc_minute = uwsgi_cron_delta->tm_min;
612
if (current_cron->hour == -1)
613
uc_hour = uwsgi_cron_delta->tm_hour;
614
if (current_cron->month == -1)
615
uc_month = uwsgi_cron_delta->tm_mon;
616
if (current_cron->day == -1)
617
uc_day = uwsgi_cron_delta->tm_mday;
618
if (current_cron->week == -1)
619
uc_week = uwsgi_cron_delta->tm_wday;
632
// negative values as interval -1 = * , -5 = */5
633
if (current_cron->minute < 0) {
634
if ((uwsgi_cron_delta->tm_min % abs(current_cron->minute)) == 0) {
635
uc_minute = uwsgi_cron_delta->tm_min;
638
if (current_cron->hour < 0) {
639
if ((uwsgi_cron_delta->tm_hour % abs(current_cron->hour)) == 0) {
640
uc_hour = uwsgi_cron_delta->tm_hour;
643
if (current_cron->month < 0) {
644
if ((uwsgi_cron_delta->tm_hour % abs(current_cron->month)) == 0) {
645
uc_month = uwsgi_cron_delta->tm_mon;
648
if (current_cron->day < 0) {
649
if ((uwsgi_cron_delta->tm_mday % abs(current_cron->day)) == 0) {
650
uc_day = uwsgi_cron_delta->tm_mday;
653
if (current_cron->week < 0) {
654
if ((uwsgi_cron_delta->tm_wday % abs(current_cron->week)) == 0) {
655
uc_week = uwsgi_cron_delta->tm_wday;
621
659
int run_task = 0;
622
660
// mday and wday are ORed
623
if (current_cron->day != -1 && current_cron->week != -1) {
661
if (current_cron->day >= 0 && current_cron->week >= 0) {
624
662
if (uwsgi_cron_delta->tm_min == uc_minute && uwsgi_cron_delta->tm_hour == uc_hour && uwsgi_cron_delta->tm_mon == uc_month && (uwsgi_cron_delta->tm_mday == uc_day || uwsgi_cron_delta->tm_wday == uc_week)) {
734
772
stats_send_llu("\"delta_requests\": %llu, ", uwsgi.workers[i + 1].delta_requests);
735
773
stats_send_llu("\"exceptions\": %llu, ", uwsgi.workers[i + 1].exceptions);
736
774
stats_send_llu("\"signals\": %llu, ", uwsgi.workers[i + 1].signals);
775
stats_send_llu("\"static_offload_threads\": %llu, ", uwsgi.workers[i + 1].static_offload_threads);
738
777
if (uwsgi.workers[i + 1].cheaped) {
739
778
fprintf(output, "\"status\": \"cheap\", ");