diff --git a/checkin_notes b/checkin_notes index d6e1c94421..4b14e9d0ab 100755 --- a/checkin_notes +++ b/checkin_notes @@ -1653,3 +1653,20 @@ David 8 Feb 2006 create_account_action.php win_build/ boinc_cli_curl.vcproj + +David 8 Feb 2006 + - Change the way the manager learns about the core client's network status. + Replace the GUI RPC with a new one, + It returns: + 0 if currently have network connections + 1 if need a physical connection + 2 if don't have connections, and don't need any + + client/ + acct_setup.C + client_state.C,h + gui_rpc_server_ops.C + net_xfer_curl.C + lib/ + gui_rpc_client.h + gui_rpc_client_ops.C diff --git a/client/acct_setup.C b/client/acct_setup.C index c79b337f45..95075584a7 100644 --- a/client/acct_setup.C +++ b/client/acct_setup.C @@ -195,7 +195,7 @@ void LOOKUP_WEBSITE_OP::handle_reply(int http_op_retval, int CurlResult) { // Set a flag that will signal the Manager to that effect // if (CurlResult == CURLE_COULDNT_RESOLVE_HOST) { - gstate.want_network_flag = true; + gstate.need_physical_connection = true; } } diff --git a/client/client_state.C b/client/client_state.C index fd8041d30c..e8507abb39 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -119,7 +119,7 @@ CLIENT_STATE::CLIENT_STATE() { cpu_sched_last_time = 0; total_wall_cpu_time_this_period = 0; must_schedule_cpus = true; - want_network_flag = false; + need_physical_connection = false; have_sporadic_connection = false; no_gui_rpc = false; have_tentative_project = false; @@ -1415,27 +1415,26 @@ int CLIENT_STATE::detach_project(PROJECT* project) { return 0; } -// Return true if the core client wants a network connection, -// or if we've been using the network in the last 10 seconds +// Return: +// 0 if we have network connections open +// 1 if we need a physical connection +// 2 if we don't have any connections, and don't need any +// There's a 10-second slop factor; +// if we've done network comm in the last 10 seconds, +// we act as if we're doing it now. // (so that polling mechanisms have a change to trigger) // -bool CLIENT_STATE::want_network() { - static double last_true_return=0; +int CLIENT_STATE::network_status() { + static double last_comm_time=0; - if (http_ops->nops()) goto return_true; - // if we're using network, return true - if (network_suspended) goto return_false; - if (want_network_flag) goto return_true; - if (active_tasks.want_network()) goto return_true; -return_false: - if ((now - last_true_return) > 10) { - have_sporadic_connection = false; - return false; + if (http_ops->nops()) { + last_comm_time = now; } - return true; -return_true: - last_true_return = now; - return true; + if (now - last_comm_time < 10) return 0; + if (need_physical_connection) return 1; + if (active_tasks.want_network()) return 1; + have_sporadic_connection = false; + return 2; } // There's now a network connection, after some period of disconnection. diff --git a/client/client_state.h b/client/client_state.h index d44bb00dfe..03083a2e3c 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -228,21 +228,21 @@ public: int detach_project(PROJECT*); int report_result_error(RESULT&, const char *format, ...); int reset_project(PROJECT*); - bool want_network_flag; + bool need_physical_connection; // client wants to do network comm and no physical connection exists. // Initially false; set whenever a Curl operation - // returns CURLE_COULDNT_RESOLVE_HOST; - // cleared whenever a Curl operation returns anything else - // TODO: is this the best way to do this? - // won't it set this flag when user enters URL with - // non-existent URL, e.g.? + // returns CURLE_COULDNT_RESOLVE_HOST, + // and a subsequent request to a highly-available site + // also returns CURLE_COULDNT_RESOLVE_HOST. + // cleared whenever we transfer data, or an operation + // returns some other value // bool have_sporadic_connection; // we have a network connection, but it's likely to go away soon, // so do as much network comm as possible // (e.g. report completed results) // - bool want_network(); + int network_status(); void network_available(); bool no_gui_rpc; private: @@ -260,12 +260,15 @@ private: // --------------- cpu_sched.C: private: - void adjust_debts(); bool must_schedule_cpus; + void assign_results_to_projects(); + bool schedule_largest_debt_project(double expected_pay_off); + bool schedule_earliest_deadline_result(); + void adjust_debts(); bool schedule_cpus(); + void enforce_schedule(); bool no_work_for_a_cpu(); bool rr_misses_deadline(double, double); - bool edf_misses_deadline(double); void set_scheduler_mode(); public: @@ -310,10 +313,6 @@ private: int choose_version_num(char*, SCHEDULER_REPLY&); int app_finished(ACTIVE_TASK&); - void assign_results_to_projects(); - bool schedule_largest_debt_project(double expected_pay_off); - bool schedule_earliest_deadline_result(); - void enforce_schedule(); bool start_apps(); bool handle_finished_apps(); void handle_file_xfer_apps(); diff --git a/client/gui_rpc_server_ops.C b/client/gui_rpc_server_ops.C index 5d9b257806..cb505aa753 100644 --- a/client/gui_rpc_server_ops.C +++ b/client/gui_rpc_server_ops.C @@ -514,11 +514,8 @@ static void handle_get_statistics(char*, MIOFILE& fout) { fout.printf("\n"); } -static void handle_network_query(char*, MIOFILE& fout) { - fout.printf( - "%d\n", - gstate.want_network()?1:0 - ); +static void handle_network_status(char*, MIOFILE& fout) { + fout.printf("%d\n", gstate.network_status()); } static void handle_network_available(char*, MIOFILE&) { @@ -856,8 +853,8 @@ int GUI_RPC_CONN::handle_rpc() { handle_get_host_info(request_msg, mf); } else if (match_tag(request_msg, "")) { diff --git a/client/net_xfer_curl.C b/client/net_xfer_curl.C index dcd27796c0..5b8ccd96a0 100644 --- a/client/net_xfer_curl.C +++ b/client/net_xfer_curl.C @@ -258,12 +258,11 @@ void NET_XFER_SET::got_select(FDSET_GROUP&, double timeout) { // get the data waiting for transfer in or out // use timeout value so that we don't hog CPU in this loop // - bool got_data = false; while (1) { curlMErr = curl_multi_perform(g_curlMulti, &iRunning); if (curlMErr != CURLM_CALL_MULTI_PERFORM) break; + gstate.need_physical_connection = false; if (dtime() - gstate.now > timeout) break; - got_data = true; } // read messages from curl that may have come in from the above loop @@ -348,7 +347,7 @@ void NET_XFER_SET::got_select(FDSET_GROUP&, double timeout) { std::string url = "http://www.google.com"; gstate.lookup_website_op.do_rpc(url); } else { - gstate.want_network_flag = false; + gstate.need_physical_connection = false; } msg_printf(0, MSG_ERROR, "HTTP error: %s", nxf->strCurlResult); nxf->http_op_retval = ERR_HTTP_ERROR; diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index b9cb7bdba3..e908bfcd1b 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -558,7 +558,7 @@ public: int acct_mgr_info(ACCT_MGR_INFO&); const char* mode_name(int mode); int get_statistics(PROJECTS&); - int network_query(int&); + int network_status(int&); int network_available(); int get_project_init_status(PROJECT_INIT_STATUS& pis); diff --git a/lib/gui_rpc_client_ops.C b/lib/gui_rpc_client_ops.C index 7d5c7bf1e2..facec30177 100644 --- a/lib/gui_rpc_client_ops.C +++ b/lib/gui_rpc_client_ops.C @@ -1113,15 +1113,15 @@ int RPC_CLIENT::get_statistics(PROJECTS& p) { return 0; } -int RPC_CLIENT::network_query(int& want_network) { +int RPC_CLIENT::network_status(int& status) { RPC rpc(this); int retval; char buf[256]; - retval = rpc.do_rpc("\n"); + retval = rpc.do_rpc("\n"); if (retval) return retval; while (rpc.fin.fgets(buf, 256)) { - if (parse_int(buf, "", want_network)) { + if (parse_int(buf, "", status)) { return 0; } }