network status GUI RPC

svn path=/trunk/boinc/; revision=9424
This commit is contained in:
David Anderson 2006-02-09 00:56:51 +00:00
parent c85026b147
commit 1d290cbd8c
8 changed files with 57 additions and 46 deletions

View File

@ -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 <network_query> GUI RPC with a new one, <network_status>
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

View File

@ -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;
}
}

View File

@ -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.

View File

@ -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();

View File

@ -514,11 +514,8 @@ static void handle_get_statistics(char*, MIOFILE& fout) {
fout.printf("</statistics>\n");
}
static void handle_network_query(char*, MIOFILE& fout) {
fout.printf(
"<want_network>%d</want_network>\n",
gstate.want_network()?1:0
);
static void handle_network_status(char*, MIOFILE& fout) {
fout.printf("<status>%d</status>\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, "<get_statistics")) {
handle_get_statistics(request_msg, mf);
} else if (match_tag(request_msg, "<network_query")) {
handle_network_query(request_msg, mf);
} else if (match_tag(request_msg, "<network_status")) {
handle_network_status(request_msg, mf);
} else if (match_tag(request_msg, "<network_available")) {
handle_network_available(request_msg, mf);
} else if (match_tag(request_msg, "<get_newer_version>")) {

View File

@ -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;

View File

@ -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);

View File

@ -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("<network_query/>\n");
retval = rpc.do_rpc("<network_status/>\n");
if (retval) return retval;
while (rpc.fin.fgets(buf, 256)) {
if (parse_int(buf, "<want_network>", want_network)) {
if (parse_int(buf, "<status>", status)) {
return 0;
}
}