~ubuntu-branches/ubuntu/saucy/uwsgi/saucy

« back to all changes in this revision

Viewing changes to master_utils.c

  • Committer: Package Import Robot
  • Author(s): Janos Guljas
  • Date: 2012-04-30 17:35:22 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120430173522-qucwu1au3s9bflhb
Tags: 1.2+dfsg-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
int uwsgi_calc_cheaper(void) {
9
9
 
10
10
        int i;
11
 
 
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; 
18
 
        last_check = now; 
 
11
        static time_t last_check = 0;
 
12
        int check_interval = uwsgi.shared->options[UWSGI_OPTION_MASTER_INTERVAL];
 
13
 
 
14
        if (!last_check) last_check = time(NULL);
 
15
 
 
16
        time_t now = time(NULL);
 
17
        if (!check_interval)
 
18
                check_interval = 1;
 
19
 
 
20
        if ( (now - last_check) < check_interval) return 1;
 
21
 
 
22
        last_check = now;
19
23
 
20
24
        int needed_workers = uwsgi.cheaper_algo();
21
25
 
541
545
                        uc_month = ucron->month;
542
546
                        uc_week = ucron->week;
543
547
 
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;
 
552
                                }
 
553
                        }
 
554
                        if (ucron->hour < 0) {
 
555
                                if ((uwsgi_cron_delta->tm_hour % abs(ucron->hour)) == 0) {
 
556
                                        uc_hour = uwsgi_cron_delta->tm_hour;
 
557
                                }
 
558
                        }
 
559
                        if (ucron->month < 0) {
 
560
                                if ((uwsgi_cron_delta->tm_mon % abs(ucron->month)) == 0) {
 
561
                                        uc_month = uwsgi_cron_delta->tm_mon;
 
562
                                }
 
563
                        }
 
564
                        if (ucron->day < 0) {
 
565
                                if ((uwsgi_cron_delta->tm_mday % abs(ucron->day)) == 0) {
 
566
                                        uc_day = uwsgi_cron_delta->tm_mday;
 
567
                                }
 
568
                        }
 
569
                        if (ucron->week < 0) {
 
570
                                if ((uwsgi_cron_delta->tm_wday % abs(ucron->week)) == 0) {      
 
571
                                        uc_week = uwsgi_cron_delta->tm_wday;
 
572
                                }
 
573
                        }
554
574
 
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)) {
559
579
                                        run_task = 1;
560
580
                                }
598
618
                return;
599
619
        }
600
620
 
 
621
        // fix month
 
622
        uwsgi_cron_delta->tm_mon++;
 
623
 
601
624
        while (current_cron) {
602
625
 
603
 
 
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;
609
631
 
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;
 
636
                        }
 
637
                }
 
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;
 
641
                        }
 
642
                }
 
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;
 
646
                        }
 
647
                }
 
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;
 
651
                        }
 
652
                }
 
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;
 
656
                        }
 
657
                }
620
658
 
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)) {
625
663
                                run_task = 1;
626
664
                        }
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);
737
776
 
738
777
                if (uwsgi.workers[i + 1].cheaped) {
739
778
                        fprintf(output, "\"status\": \"cheap\", ");