diff --git a/checkin_notes b/checkin_notes index f39a19d329..2e6c1fbe5c 100755 --- a/checkin_notes +++ b/checkin_notes @@ -3179,3 +3179,18 @@ David Feb 12 2003 test.inc tools/ add.C + +David Feb 12 2003 + - changed "exit_after" to "exit_after_app_started_secs" + and changed its null value from -1 to 0. + - don't ask a scheduler for work if in exit_when_idle mode + and we've already contacted scheduler + - remove exit_when_idle clause from backoff after no work available + + client/ + client_state.C,h + cs_apps.C + cs_scheduler.C + scheduler_op.C + test/ + test_time.php diff --git a/client/client_state.C b/client/client_state.C index 194fac0221..cfde9c6808 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -72,7 +72,7 @@ CLIENT_STATE::CLIENT_STATE() { core_client_major_version = MAJOR_VERSION; core_client_minor_version = MINOR_VERSION; platform_name = HOST; - exit_after = -1; + exit_after_app_start_secs = 0; app_started = 0; max_transfer_rate = 9999; max_bytes = 0; @@ -1104,8 +1104,8 @@ void CLIENT_STATE::parse_cmdline(int argc, char** argv) { run_time_test = false; continue; } - if (!strcmp(argv[i], "-exit_after")) { - exit_after = atoi(argv[++i]); + if (!strcmp(argv[i], "-exit_after_app_start")) { + exit_after_app_start_secs = atoi(argv[++i]); continue; } @@ -1172,13 +1172,16 @@ void CLIENT_STATE::parse_env_vars() { } } -// Returns true if the core client should exit +// Returns true if client should exit because of debugging criteria +// (timeout or idle) // bool CLIENT_STATE::time_to_exit() { - if (!exit_when_idle && (exit_after == -1)) return false; - if ((exit_after != -1) && app_started && - (difftime(time(0), app_started) >= exit_after)) { - printf("exiting because time is up: %d\n", exit_after); + if (!exit_when_idle && !exit_after_app_start_secs) return false; + if (exit_after_app_start_secs + && app_started + && (difftime(time(0), app_started) >= exit_after_app_start_secs) + ) { + printf("exiting because time is up: %d\n", exit_after_app_start_secs); return true; } if (exit_when_idle && (results.size() == 0) && contacted_sched_server) { diff --git a/client/client_state.h b/client/client_state.h index c82fd3dac0..becd7dfb5e 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -102,8 +102,10 @@ private: unsigned int nslots; bool run_time_test; bool activities_suspended; - int exit_after; + int exit_after_app_start_secs; + // if nonzero, exit this many seconds after starting an app time_t app_started; + // when the most recent app was started int max_transfer_rate, max_bytes; int parse_account_files(); diff --git a/client/cs_apps.C b/client/cs_apps.C index 3c6d9fa1a5..0db82d5466 100644 --- a/client/cs_apps.C +++ b/client/cs_apps.C @@ -192,8 +192,9 @@ bool CLIENT_STATE::start_apps() { atp->state = PROCESS_COULDNT_START; atp->result->active_task_state = PROCESS_COULDNT_START; report_project_error( - *(atp->result),retval, - "Couldn't start the app for this result.\n" ); + *(atp->result), retval, + "Couldn't start the app for this result.\n" + ); } action = true; set_client_state_dirty("start_apps"); diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index b24103da0c..2dff3d76c7 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -250,12 +250,17 @@ bool CLIENT_STATE::some_project_rpc_ok() { bool CLIENT_STATE::scheduler_rpc_poll() { double work_secs; PROJECT* p; - bool action=false, below_low_water; + bool action=false, below_low_water, should_get_work; switch(scheduler_op->state) { case SCHEDULER_OP_STATE_IDLE: - below_low_water = (current_water_days() <= global_prefs.low_water_days); - if (below_low_water && some_project_rpc_ok()) { + if (exit_when_idle && contacted_sched_server) { + should_get_work = false; + } else { + below_low_water = (current_water_days() <= global_prefs.low_water_days); + should_get_work = below_low_water && some_project_rpc_ok(); + } + if (should_get_work) { compute_resource_debts(); scheduler_op->init_get_work(); action = true; diff --git a/client/scheduler_op.C b/client/scheduler_op.C index 68546f9d09..0489e3af55 100644 --- a/client/scheduler_op.C +++ b/client/scheduler_op.C @@ -419,7 +419,7 @@ bool SCHEDULER_OP::poll() { // if we asked for work and didn't get any, // back off this project // - if (must_get_work && nresults==0 &&!gstate.exit_when_idle) { + if (must_get_work && nresults==0) { backoff(project, "No work from project\n"); } else { project->nrpc_failures = 0; diff --git a/test/test_time.php b/test/test_time.php index b9c6ee55e9..7f4b890d15 100644 --- a/test/test_time.php +++ b/test/test_time.php @@ -30,7 +30,7 @@ $project->start_feeder(); $app_time = 0; - $host->run("-exit_after 400"); + $host->run("-exit_after_app_start 400"); $app_time += $host->read_cpu_time_file("app.time"); $host->run("-exit_when_idle"); $project->stop();