attach project poll RPC

svn path=/trunk/boinc/; revision=7296
This commit is contained in:
David Anderson 2005-08-13 03:19:22 +00:00
parent e113fa81e0
commit 7c716dc8db
16 changed files with 112 additions and 69 deletions

View File

@ -10499,3 +10499,25 @@ Rom 12 Aug 2005
BOINCGUI.pjd
ValidateURL.cpp, .h
WizAttachProject.cpp, .h
David 12 Aug 2005
- Added project_attach_poll() GUI RPC.
- removed MSG_ALERT messages on attach succeed/fail
- added class PROJECT_ATTACH in core client.
Its error_num field stores result of last attach
- attach failure reasons now have ERR_* values
client/
acct_mgr.C
acct_setup.h
client_state.h
client_types.h
cs_account.C
cs_cmdline.C
gui_rpc_server_ops.C
scheduler_op.C
lib/
error_numbers.h
gui_rpc_client.h
gui_rpc_client_ops.C
util.C

View File

@ -151,7 +151,7 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
}
} else {
msg_printf(NULL, MSG_INFO, "Attaching to %s", acct.url.c_str());
gstate.add_project(acct.url.c_str(), acct.authenticator.c_str(), false);
gstate.add_project(acct.url.c_str(), acct.authenticator.c_str());
}
}
if (accounts.size() == 0) {

View File

@ -71,4 +71,8 @@ struct LOOKUP_WEBSITE_OP: public GUI_HTTP_OP {
LOOKUP_WEBSITE_OP(){error_num = BOINC_SUCCESS;}
};
struct PROJECT_ATTACH {
int error_num;
};
#endif

View File

@ -107,6 +107,7 @@ public:
LOOKUP_ACCOUNT_OP lookup_account_op;
CREATE_ACCOUNT_OP create_account_op;
LOOKUP_WEBSITE_OP lookup_website_op;
PROJECT_ATTACH project_attach;
int core_client_major_version;
int core_client_minor_version;
@ -227,7 +228,7 @@ private:
// --------------- cs_account.C:
public:
int add_project(const char* master_url, const char* authenticator, bool show_alrts);
int add_project(const char* master_url, const char* authenticator);
private:
int parse_account_files();
int parse_preferences_for_user_files();

View File

@ -144,13 +144,6 @@ struct DAILY_STATS {
int parse(FILE*);
};
// reasons for attach failure
#define ATTACH_FAIL_INIT 1
#define ATTACH_FAIL_DOWNLOAD 2
#define ATTACH_FAIL_PARSE 3
#define ATTACH_FAIL_BAD_KEY 4
#define ATTACH_FAIL_FILE_WRITE 5
class PROJECT {
public:
// the following items come from the account file
@ -216,8 +209,6 @@ public:
// need to fetch and parse the master URL
bool sched_rpc_pending; // contact scheduling server for preferences
bool tentative; // master URL and account ID not confirmed
bool show_alerts; // show alerts on project attach fail
// (used for attach via GUI)
bool anonymous_platform; // app_versions.xml file found in project dir;
// use those apps rather then getting from server
bool non_cpu_intensive;

View File

@ -347,9 +347,7 @@ int PROJECT::write_statistics_file() {
return 0;
}
int CLIENT_STATE::add_project(
const char* master_url, const char* _auth, bool show_alerts
) {
int CLIENT_STATE::add_project(const char* master_url, const char* _auth) {
char path[256], canonical_master_url[256], auth[256];
PROJECT* project;
FILE* f;
@ -359,14 +357,7 @@ int CLIENT_STATE::add_project(
strip_whitespace(canonical_master_url);
canonicalize_master_url(canonical_master_url);
if (!valid_master_url(canonical_master_url)) {
msg_printf(0, MSG_ERROR, "Invalid project URL: %s", canonical_master_url);
if (show_alerts) {
msg_printf(0, MSG_ALERT_ERROR,
"%s is not a valid URL.\n"
"You may have typed the URL incorrectly.\n",
canonical_master_url
);
}
msg_printf(0, MSG_ERROR, "Invalid URL: %s", canonical_master_url);
return ERR_INVALID_URL;
}
@ -374,13 +365,6 @@ int CLIENT_STATE::add_project(
strip_whitespace(auth);
if (!strlen(auth)) {
msg_printf(0, MSG_ERROR, "Missing account key");
if (show_alerts) {
msg_printf(0, MSG_ALERT_ERROR,
"Missing account key.\n"
"Visit the project's web site\n"
"to get your account key."
);
}
return ERR_AUTHENTICATOR;
}
@ -388,11 +372,6 @@ int CLIENT_STATE::add_project(
//
if (lookup_project(canonical_master_url)) {
msg_printf(0, MSG_ERROR, "Already attached to %s", canonical_master_url);
if (show_alerts) {
msg_printf(0, MSG_ALERT_INFO,
"Already attached to %s", canonical_master_url
);
}
return ERR_ALREADY_ATTACHED;
}
@ -403,7 +382,6 @@ int CLIENT_STATE::add_project(
strcpy(project->authenticator, auth);
project->tentative = true;
project->show_alerts = show_alerts;
retval = project->write_account_file();
if (retval) return retval;
@ -428,42 +406,42 @@ int CLIENT_STATE::add_project(
// called when the client fails to attach to a project
//
void PROJECT::attach_failed(int reason) {
int msg_type = show_alerts?MSG_ALERT_ERROR:MSG_ERROR;
switch(reason){
case ATTACH_FAIL_INIT:
msg_printf(this, msg_type,
void PROJECT::attach_failed(int error_num) {
gstate.project_attach.error_num = error_num;
switch(error_num){
case ERR_ATTACH_FAIL_INIT:
msg_printf(this, MSG_ERROR,
"Couldn't connect to URL %s.\n"
"Please check URL.",
master_url
);
break;
case ATTACH_FAIL_DOWNLOAD:
msg_printf(this, msg_type,
case ERR_ATTACH_FAIL_DOWNLOAD:
msg_printf(this, MSG_ERROR,
"Couldn't access URL %s.\n"
"The project's servers may be down,\n"
"in which case please try again later.",
master_url
);
break;
case ATTACH_FAIL_PARSE:
msg_printf(this, msg_type,
case ERR_ATTACH_FAIL_PARSE:
msg_printf(this, MSG_ERROR,
"The page at %s contains no BOINC information.\n"
"It may not be the URL of a BOINC project.\n"
"Please check the URL and try again.",
master_url
);
break;
case ATTACH_FAIL_BAD_KEY:
msg_printf(this, msg_type,
case ERR_ATTACH_FAIL_BAD_KEY:
msg_printf(this, MSG_ERROR,
"The account key you provided for %s\n"
"was not recognized as a valid account key.\n"
"Please check the account key and try again.",
master_url
);
break;
case ATTACH_FAIL_FILE_WRITE:
msg_printf(this, msg_type,
case ERR_ATTACH_FAIL_FILE_WRITE:
msg_printf(this, MSG_ERROR,
"BOINC was unable to create an account file for %s on your disk.\n"
"Please check file system permissions and try again.\n",
master_url

View File

@ -276,7 +276,7 @@ void CLIENT_STATE::do_cmdline_actions() {
}
if (strlen(attach_project_url)) {
add_project(attach_project_url, attach_project_auth, false);
add_project(attach_project_url, attach_project_auth);
}
}

View File

@ -200,7 +200,8 @@ static void handle_project_attach(char* buf, MIOFILE& fout) {
fout.printf("<error>Missing authenticator</error>\n");
return;
}
gstate.add_project(url.c_str(), authenticator.c_str(), true);
gstate.add_project(url.c_str(), authenticator.c_str());
gstate.project_attach.error_num = ERR_IN_PROGRESS;
fout.printf("<success/>\n");
}
@ -577,9 +578,19 @@ static void handle_lookup_website(char* buf, MIOFILE& fout) {
}
static void handle_lookup_website_poll(char*, MIOFILE& fout) {
fout.printf("<lookup_website>\n");
fout.printf(" <error_num>%d</error_num>\n", gstate.lookup_website_op.error_num);
fout.printf("</lookup_website>\n");
fout.printf(
"<lookup_website>\n"
" <error_num>%d</error_num>\n"
"</lookup_website>\n",
gstate.lookup_website_op.error_num
);
}
static void handle_project_attach_poll(char*, MIOFILE& fout) {
fout.printf(
"<error_num>%d</error_num>\n",
gstate.project_attach.error_num
);
}
int GUI_RPC_CONN::handle_rpc() {
@ -719,10 +730,12 @@ int GUI_RPC_CONN::handle_rpc() {
handle_create_account(request_msg, mf);
} else if (match_tag(request_msg, "<create_account_poll")) {
handle_create_account_poll(request_msg, mf);
} else if (match_tag(request_msg, "<lookup_website_poll")) {
handle_lookup_website_poll(request_msg, mf);
} else if (match_tag(request_msg, "<lookup_website")) {
handle_lookup_website(request_msg, mf);
} else if (match_tag(request_msg, "<lookup_website_poll")) {
handle_lookup_website_poll(request_msg, mf);
} else if (match_tag(request_msg, "<project_attach_poll")) {
handle_project_attach_poll(request_msg, mf);
} else {
mf.printf("<error>unrecognized op</error>\n");
}

View File

@ -63,7 +63,7 @@ bool SCHEDULER_OP::check_master_fetch_start() {
"Couldn't start master page download: %s", boincerror(retval)
);
if (p->tentative) {
p->attach_failed(ATTACH_FAIL_INIT);
p->attach_failed(ERR_ATTACH_FAIL_INIT);
} else {
p->master_fetch_failures++;
backoff(p, "Master page fetch failed\n");
@ -183,7 +183,7 @@ void SCHEDULER_OP::backoff(PROJECT* p, const char *error_msg ) {
msg_printf(p, MSG_ERROR, error_msg);
if (p->tentative) {
p->attach_failed(ATTACH_FAIL_INIT);
p->attach_failed(ERR_ATTACH_FAIL_INIT);
return;
}
@ -388,7 +388,7 @@ bool SCHEDULER_OP::poll() {
if (cur_proj->tentative) {
PROJECT* project_temp = cur_proj;
cur_proj = 0; // keep detach(0) from removing HTTP OP
project_temp->attach_failed(ATTACH_FAIL_PARSE);
project_temp->attach_failed(ERR_ATTACH_FAIL_PARSE);
err = true;
} else {
cur_proj->master_fetch_failures++;
@ -414,7 +414,7 @@ bool SCHEDULER_OP::poll() {
if (cur_proj->tentative) {
PROJECT* project_temp = cur_proj;
cur_proj = 0;
project_temp->attach_failed(ATTACH_FAIL_DOWNLOAD);
project_temp->attach_failed(ERR_ATTACH_FAIL_DOWNLOAD);
} else {
cur_proj->master_fetch_failures++;
backoff(cur_proj, "Master file fetch failed\n");
@ -469,15 +469,17 @@ bool SCHEDULER_OP::poll() {
//
if (cur_proj->tentative) {
if (retval || strlen(cur_proj->user_name)==0) {
cur_proj->attach_failed(ATTACH_FAIL_BAD_KEY);
cur_proj->attach_failed(ERR_ATTACH_FAIL_BAD_KEY);
} else {
cur_proj->tentative = false;
retval = cur_proj->write_account_file();
if (retval) {
cur_proj->attach_failed(ATTACH_FAIL_FILE_WRITE);
} else if (cur_proj->show_alerts) {
msg_printf(cur_proj, MSG_ALERT_INFO,
"Successfully attached to %s", cur_proj->get_project_name()
cur_proj->attach_failed(ERR_ATTACH_FAIL_FILE_WRITE);
} else {
gstate.project_attach.error_num = 0;
msg_printf(cur_proj, MSG_INFO,
"Successfully attached to %s",
cur_proj->get_project_name()
);
}
}

View File

@ -2,6 +2,12 @@
$project_news = array(
array("August 9, 2005",
"BOINC is transitioning to use <a href=http://curl.haxx.se/>libcurl</a>
for HTTP operations.
This will allow BOINC to use HTTPS (secure HTTP)
for scheduler requests and file transfers."
),
array("August 3, 2005",
"Non-open-source code (RSAEuro and GLUT) has been removed from BOINC.
OpenSSL's crypto library is used for encryption."

View File

@ -71,7 +71,7 @@ list_item("executable",
);
list_item("upload_when_present",
"If present, indicates that the file should be uploaded
when the application that generates it exits.
when the application finishes.
");
list_item("sticky",
"If present, indicates that the file should be retained

View File

@ -60,11 +60,12 @@ computer resources
<br>
2) <a href=download.php>Download</a> and run BOINC software.
<p>
You can participate in any or all projects -- the choice is up to you.
You control the percentage of your computing power
You can participate in any or all projects,
and you control the percentage of your computing power
that goes to each project.
If you participate in several projects,
your computer will be busy even when one project has no work.
By participating in several projects,
you ensure that your computer will be kept busy
even when one project has no work.
<p>
<a href=participate.php>... more</a>

View File

@ -156,6 +156,12 @@
#define ERR_BAD_PASSWD -206
#define ERR_NONUNIQUE_EMAIL -207
#define ERR_ACCT_CREATION_DISABLED -208
#define ERR_ATTACH_FAIL_INIT -209
#define ERR_ATTACH_FAIL_DOWNLOAD -210
#define ERR_ATTACH_FAIL_PARSE -211
#define ERR_ATTACH_FAIL_BAD_KEY -212
#define ERR_ATTACH_FAIL_FILE_WRITE -213
// PLEASE: add a text description of your error to
// the text description function boincerror() in util.C.

View File

@ -564,6 +564,7 @@ public:
int create_account_poll(ACCOUNT_OUT&);
int lookup_website(int);
int lookup_website_poll();
int project_attach_poll();
};
struct RPC {

View File

@ -1570,3 +1570,16 @@ int RPC_CLIENT::lookup_website_poll() {
return lw.parse(rpc.fin);
}
int RPC_CLIENT::project_attach_poll() {
RPC rpc(this);
char buf[256];
int retval;
retval = rpc.do_rpc("<project_attach_poll/>\n");
if (retval) return retval;
retval = ERR_XML_PARSE;
if (rpc.fin.fgets(buf, 256)) {
parse_int(buf, "<error_num>", retval);
}
return retval;
}

View File

@ -954,6 +954,11 @@ const char* boincerror(int which_error) {
case ERR_USER_PERMISSION: return "user permission";
case ERR_SHMEM_NAME: return "can't get shared mem segment name";
case ERR_NO_NETWORK_CONNECTION: return "no available network connection";
case ERR_ATTACH_FAIL_INIT: return "Couldn't start master page download";
case ERR_ATTACH_FAIL_DOWNLOAD: return "Couldn't download master page";
case ERR_ATTACH_FAIL_PARSE: return "Couldn't parse master page";
case ERR_ATTACH_FAIL_BAD_KEY: return "Invalid account key";
case ERR_ATTACH_FAIL_FILE_WRITE: return "Couldn't write account file";
}
static char buf[64];
sprintf(buf, "error %d", which_error);