Ticket #508: recursive-critical-sections3.diff

File recursive-critical-sections3.diff, 2.5 KB (added by Nicolas, 16 years ago)

Fixed stupid mistake (inverted conditions)

  • api/boinc_api.C

     
    9696static volatile double fraction_done;
    9797static volatile double last_checkpoint_cpu_time;
    9898static volatile bool ready_to_checkpoint = false;
    99 static volatile bool in_critical_section;
     99static volatile int in_critical_section;
    100100static volatile double last_wu_cpu_time;
    101101static volatile bool standalone          = false;
    102102static volatile double initial_wu_cpu_time;
     
    866866        if (options.handle_trickle_downs) {
    867867            handle_trickle_down_msg();
    868868        }
    869         if (!in_critical_section && options.handle_process_control) {
     869        if (in_critical_section == 0 && options.handle_process_control) {
    870870            handle_process_control_msg();
    871871        }
    872872        if (options.backwards_compatible_graphics) {
     
    877877    // see if the core client has died, which means we need to die too
    878878    // (unless we're in a critical section)
    879879    //
    880     if (!in_critical_section && options.check_heartbeat && heartbeat_active) {
     880    if (in_critical_section == 0 && options.check_heartbeat && heartbeat_active) {
    881881        if (heartbeat_giveup_time < interrupt_count) {
    882882            fprintf(stderr,
    883883                "No heartbeat from core client for %d sec - exiting\n",
     
    947947//
    948948void worker_signal_handler(int) {
    949949    if (options.direct_process_action) {
    950         while (boinc_status.suspended && !in_critical_section) {
     950        while (boinc_status.suspended && in_critical_section == 0) {
    951951            sleep(1);   // don't use boinc_sleep() because it does FP math
    952952        }
    953953    }
     
    10501050//
    10511051int boinc_time_to_checkpoint() {
    10521052    if (ready_to_checkpoint) {
    1053         in_critical_section = true;
     1053        boinc_begin_critical_section();
    10541054        return 1;
    10551055    }
    10561056    return 0;
     
    10651065        update_app_progress(last_checkpoint_cpu_time, last_checkpoint_cpu_time);
    10661066    }
    10671067    time_until_checkpoint = (int)aid.checkpoint_period;
    1068     in_critical_section = false;
     1068    boinc_end_critical_section();
    10691069    ready_to_checkpoint = false;
    10701070
    10711071    return 0;
    10721072}
    10731073
    10741074void boinc_begin_critical_section() {
    1075     in_critical_section = true;
     1075    in_critical_section++;
    10761076}
    10771077
    10781078void boinc_end_critical_section() {
    1079     in_critical_section = false;
     1079    in_critical_section--;
     1080    //just in case...
     1081    if (in_critical_section < 0) {
     1082        in_critical_section = 0;
     1083    }
    10801084}
    10811085
    10821086int boinc_fraction_done(double x) {