mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=10659
This commit is contained in:
parent
626ac2cc5e
commit
4f5401188c
|
@ -7592,3 +7592,20 @@ David 17 July 2006
|
|||
gui_rpc_server.C,h
|
||||
sched/
|
||||
trickle_handler.C
|
||||
|
||||
David 17 July 2006
|
||||
- moved stuff related to network status out of CLIENT_STATE
|
||||
and into a new class, NET_STATUS.
|
||||
|
||||
client/
|
||||
acct_setup.C
|
||||
client_state.C,h
|
||||
cs_account.C
|
||||
cs_scheduler.C
|
||||
gui_rpc_server_ops.C
|
||||
http_curl.C
|
||||
net_stats.C,h
|
||||
pers_file_xfer.C
|
||||
scheduler_ops.C
|
||||
lib/
|
||||
app_ipc.C
|
||||
|
|
|
@ -219,7 +219,7 @@ int LOOKUP_WEBSITE_OP::do_rpc(string& url) {
|
|||
retval = gstate.gui_http.do_rpc(this, url, LOOKUP_WEBSITE_FILENAME);
|
||||
if (retval) {
|
||||
error_num = retval;
|
||||
gstate.need_physical_connection = true;
|
||||
net_status.need_physical_connection = true;
|
||||
msg_printf(0, MSG_ERROR,
|
||||
"Access to reference web site failed - check network connection or proxy configuration."
|
||||
);
|
||||
|
@ -238,7 +238,7 @@ void LOOKUP_WEBSITE_OP::handle_reply(int http_op_retval) {
|
|||
// Set a flag that will signal the Manager to that effect
|
||||
//
|
||||
if (http_op_retval) {
|
||||
gstate.need_physical_connection = true;
|
||||
net_status.need_physical_connection = true;
|
||||
msg_printf(0, MSG_ERROR,
|
||||
"Access to reference site failed - check network connection or proxy configuration."
|
||||
);
|
||||
|
|
|
@ -102,8 +102,6 @@ CLIENT_STATE::CLIENT_STATE() {
|
|||
total_wall_cpu_time_this_period = 0;
|
||||
must_schedule_cpus = true;
|
||||
must_enforce_cpu_schedule = true;
|
||||
need_physical_connection = false;
|
||||
have_sporadic_connection = false;
|
||||
no_gui_rpc = false;
|
||||
have_tentative_project = false;
|
||||
new_version_check_time = 0;
|
||||
|
@ -1344,63 +1342,6 @@ int CLIENT_STATE::detach_project(PROJECT* project) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// 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
|
||||
// 3 if a website lookup is pending (try again later)
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
int CLIENT_STATE::network_status() {
|
||||
static double last_comm_time=0;
|
||||
|
||||
if (http_ops->nops()) {
|
||||
last_comm_time = now;
|
||||
}
|
||||
if (now - last_comm_time < 10) {
|
||||
//msg_printf(0, MSG_INFO, "nops %d; return 0", http_ops->nops());
|
||||
return 0;
|
||||
}
|
||||
if (lookup_website_op.error_num == ERR_IN_PROGRESS) {
|
||||
return 3;
|
||||
}
|
||||
if (need_physical_connection) {
|
||||
//msg_printf(0, MSG_INFO, "need phys conn; return 1");
|
||||
return 1;
|
||||
}
|
||||
if (active_tasks.want_network()) {
|
||||
return 1;
|
||||
}
|
||||
have_sporadic_connection = false;
|
||||
//msg_printf(0, MSG_INFO, "returning 2");
|
||||
return 2;
|
||||
}
|
||||
|
||||
// There's now a network connection, after some period of disconnection.
|
||||
// Do all communication that we can.
|
||||
//
|
||||
void CLIENT_STATE::network_available() {
|
||||
unsigned int i;
|
||||
|
||||
have_sporadic_connection = true;
|
||||
for (i=0; i<pers_file_xfers->pers_file_xfers.size(); i++) {
|
||||
PERS_FILE_XFER* pfx = pers_file_xfers->pers_file_xfers[i];
|
||||
pfx->next_request_time = 0;
|
||||
}
|
||||
for (i=0; i<projects.size(); i++) {
|
||||
PROJECT* p = projects[i];
|
||||
p->min_rpc_time = 0;
|
||||
}
|
||||
|
||||
// tell active tasks that network is available (for Folding@home)
|
||||
//
|
||||
active_tasks.network_available();
|
||||
}
|
||||
|
||||
// Quit running applications, quit benchmarks,
|
||||
// write the client_state.xml file
|
||||
// (in principle we could also terminate net_xfers here,
|
||||
|
|
|
@ -227,22 +227,6 @@ public:
|
|||
int detach_project(PROJECT*);
|
||||
int report_result_error(RESULT&, const char *format, ...);
|
||||
int reset_project(PROJECT*);
|
||||
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,
|
||||
// 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)
|
||||
//
|
||||
int network_status();
|
||||
void network_available();
|
||||
bool no_gui_rpc;
|
||||
private:
|
||||
int link_app(PROJECT*, APP*);
|
||||
|
|
|
@ -90,7 +90,6 @@ int PROJECT::write_account_file() {
|
|||
int PROJECT::parse_account(FILE* in) {
|
||||
char buf[256];
|
||||
int retval;
|
||||
bool got_venue_prefs = false;
|
||||
|
||||
strcpy(master_url, "");
|
||||
strcpy(authenticator, "");
|
||||
|
|
|
@ -446,7 +446,7 @@ PROJECT* CLIENT_STATE::find_project_with_overdue_results() {
|
|||
if (p->suspended_via_gui) continue;
|
||||
|
||||
if (!r->ready_to_report) continue;
|
||||
if (have_sporadic_connection) {
|
||||
if (net_status.have_sporadic_connection) {
|
||||
return p;
|
||||
}
|
||||
double cushion = std::max(
|
||||
|
|
|
@ -534,7 +534,7 @@ static void handle_get_statistics(char*, MIOFILE& fout) {
|
|||
}
|
||||
|
||||
static void handle_network_status(char*, MIOFILE& fout) {
|
||||
fout.printf("<status>%d</status>\n", gstate.network_status());
|
||||
fout.printf("<status>%d</status>\n", net_status.network_status());
|
||||
}
|
||||
|
||||
static void handle_get_cc_status(MIOFILE& fout) {
|
||||
|
@ -543,13 +543,13 @@ static void handle_get_cc_status(MIOFILE& fout) {
|
|||
" <network_status>%d</network_status>\n"
|
||||
" <ams_password_error>%d</ams_password_error>\n"
|
||||
"</cc_status>\n",
|
||||
gstate.network_status(),
|
||||
net_status.network_status(),
|
||||
gstate.acct_mgr_info.password_error?1:0
|
||||
);
|
||||
}
|
||||
|
||||
static void handle_network_available(char*, MIOFILE&) {
|
||||
gstate.network_available();
|
||||
net_status.network_available();
|
||||
}
|
||||
|
||||
static void handle_get_project_init_status(char*, MIOFILE& fout) {
|
||||
|
|
|
@ -974,21 +974,11 @@ void HTTP_OP_SET::got_select(FDSET_GROUP&, double timeout) {
|
|||
sprintf(hop->error_msg, "HTTP error %d", hop->response);
|
||||
}
|
||||
}
|
||||
gstate.need_physical_connection = false;
|
||||
net_status.need_physical_connection = false;
|
||||
} else {
|
||||
strcpy(hop->error_msg, curl_easy_strerror(hop->CurlResult));
|
||||
// If operation failed,
|
||||
// it could be because there's no physical network connection.
|
||||
// Find out for sure by trying to contact google
|
||||
//
|
||||
if ((gstate.lookup_website_op.error_num != ERR_IN_PROGRESS)
|
||||
&& !gstate.need_physical_connection
|
||||
) {
|
||||
std::string url = "http://www.google.com";
|
||||
//msg_printf(0, MSG_ERROR, "need_phys_conn %d trying google", gstate.need_physical_connection);
|
||||
gstate.lookup_website_op.do_rpc(url);
|
||||
}
|
||||
hop->http_op_retval = ERR_HTTP_ERROR;
|
||||
net_status.got_http_error();
|
||||
}
|
||||
|
||||
if (!hop->http_op_retval && hop->http_op_type == HTTP_OP_POST2) {
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
|
||||
#define EXP_DECAY_RATE (1./3600)
|
||||
|
||||
NET_STATUS net_status;
|
||||
|
||||
NET_STATS::NET_STATS() {
|
||||
last_time = 0;
|
||||
memset(&up, 0, sizeof(up));
|
||||
|
@ -141,4 +143,75 @@ int NET_STATS::parse(MIOFILE& in) {
|
|||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
||||
// 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
|
||||
// 3 if a website lookup is pending (try again later)
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
int NET_STATUS::network_status() {
|
||||
static double last_comm_time=0;
|
||||
|
||||
if (gstate.http_ops->nops()) {
|
||||
last_comm_time = gstate.now;
|
||||
}
|
||||
if (gstate.now - last_comm_time < 10) {
|
||||
//msg_printf(0, MSG_INFO, "nops %d; return 0", http_ops->nops());
|
||||
return 0;
|
||||
}
|
||||
if (gstate.lookup_website_op.error_num == ERR_IN_PROGRESS) {
|
||||
return 3;
|
||||
}
|
||||
if (need_physical_connection) {
|
||||
//msg_printf(0, MSG_INFO, "need phys conn; return 1");
|
||||
return 1;
|
||||
}
|
||||
if (gstate.active_tasks.want_network()) {
|
||||
return 1;
|
||||
}
|
||||
have_sporadic_connection = false;
|
||||
//msg_printf(0, MSG_INFO, "returning 2");
|
||||
return 2;
|
||||
}
|
||||
|
||||
// There's now a network connection, after some period of disconnection.
|
||||
// Do all communication that we can.
|
||||
//
|
||||
void NET_STATUS::network_available() {
|
||||
unsigned int i;
|
||||
|
||||
have_sporadic_connection = true;
|
||||
for (i=0; i<gstate.pers_file_xfers->pers_file_xfers.size(); i++) {
|
||||
PERS_FILE_XFER* pfx = gstate.pers_file_xfers->pers_file_xfers[i];
|
||||
pfx->next_request_time = 0;
|
||||
}
|
||||
for (i=0; i<gstate.projects.size(); i++) {
|
||||
PROJECT* p = gstate.projects[i];
|
||||
p->min_rpc_time = 0;
|
||||
}
|
||||
|
||||
// tell active tasks that network is available (for Folding@home)
|
||||
//
|
||||
gstate.active_tasks.network_available();
|
||||
}
|
||||
|
||||
// An HTTP operation failed;
|
||||
// it could be because there's no physical network connection.
|
||||
// Find out for sure by trying to contact google
|
||||
//
|
||||
void NET_STATUS::got_http_error() {
|
||||
if ((gstate.lookup_website_op.error_num != ERR_IN_PROGRESS)
|
||||
&& !need_physical_connection
|
||||
) {
|
||||
std::string url = "http://www.google.com";
|
||||
//msg_printf(0, MSG_ERROR, "need_phys_conn %d trying google", gstate.need_physical_connection);
|
||||
gstate.lookup_website_op.do_rpc(url);
|
||||
}
|
||||
}
|
||||
|
||||
const char *BOINC_RCSID_733b4006f5 = "$Id$";
|
||||
|
|
|
@ -56,4 +56,31 @@ public:
|
|||
int parse(MIOFILE&);
|
||||
};
|
||||
|
||||
class NET_STATUS {
|
||||
public:
|
||||
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,
|
||||
// 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)
|
||||
//
|
||||
int network_status();
|
||||
void network_available();
|
||||
void got_http_error();
|
||||
NET_STATUS() {
|
||||
need_physical_connection = false;
|
||||
have_sporadic_connection = false;
|
||||
}
|
||||
};
|
||||
|
||||
extern NET_STATUS net_status;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -366,7 +366,7 @@ void PERS_FILE_XFER::do_backoff() {
|
|||
|
||||
// don't count it as a server failure if network is down
|
||||
//
|
||||
if (!gstate.need_physical_connection) {
|
||||
if (!net_status.need_physical_connection) {
|
||||
nretry++;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ void SCHEDULER_OP::backoff(PROJECT* p, const char *error_msg ) {
|
|||
|
||||
// if network is down, don't count it as RPC failure
|
||||
//
|
||||
if (!gstate.need_physical_connection) {
|
||||
if (!net_status.need_physical_connection) {
|
||||
p->nrpc_failures++;
|
||||
}
|
||||
//msg_printf(p, MSG_INFO, "nrpc_failures %d need_conn %d", p->nrpc_failures, gstate.need_physical_connection);
|
||||
|
|
|
@ -26,13 +26,12 @@
|
|||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#include "app_ipc.h"
|
||||
#include "parse.h"
|
||||
#include "error_numbers.h"
|
||||
#include "util.h"
|
||||
#include "filesys.h"
|
||||
#include "miofile.h"
|
||||
|
||||
#include "app_ipc.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
|
Loading…
Reference in New Issue