*** empty log message ***

svn path=/trunk/boinc/; revision=5616
This commit is contained in:
David Anderson 2005-03-09 23:28:37 +00:00
parent 7b69b9209f
commit 41d4f31cca
7 changed files with 48 additions and 62 deletions

View File

@ -25741,3 +25741,14 @@ David 9 Mar 2005
client/
gui_rpc_server.C
David 9 Mar 2005
- get rid of the STRING256 type, and change things to std::string
- subscript error in SCHEDULER_OP::update_urls().
Not sure if this could cause the project-clobber bug
client/
client_types.C,h
cs_prefs.C
cs_scheduler.C
scheduler_op.C,h

View File

@ -106,7 +106,7 @@ PROJECT::~PROJECT() {
//
int PROJECT::parse_state(MIOFILE& in) {
char buf[256];
STRING256 sched_url;
std::string sched_url;
string str1, str2;
int retval;
double x;
@ -116,7 +116,7 @@ int PROJECT::parse_state(MIOFILE& in) {
init();
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</project>")) return 0;
else if (parse_str(buf, "<scheduler_url>", sched_url.text, sizeof(sched_url.text))) {
else if (parse_str(buf, "<scheduler_url>", sched_url)) {
scheduler_urls.push_back(sched_url);
continue;
}
@ -268,7 +268,7 @@ int PROJECT::write_state(MIOFILE& out, bool gui_rpc) {
for (i=0; i<scheduler_urls.size(); i++) {
out.printf(
" <scheduler_url>%s</scheduler_url>\n",
scheduler_urls[i].text
scheduler_urls[i].c_str()
);
}
if (strlen(code_sign_key)) {
@ -283,7 +283,8 @@ int PROJECT::write_state(MIOFILE& out, bool gui_rpc) {
return 0;
}
// copy fields from "p" into "this" that are stored in client_state.xml
// Some project data is stored in account file, other in client_state.xml
// Copy fields that are stored in client_state.xml from "p" into "this"
//
void PROJECT::copy_state_fields(PROJECT& p) {
scheduler_urls = p.scheduler_urls;
@ -471,7 +472,7 @@ bool FILE_INFO::verify_existing_file() {
//
int FILE_INFO::parse(MIOFILE& in, bool from_server) {
char buf[256], buf2[1024];
STRING256 url;
std::string url;
PERS_FILE_XFER *pfxp;
int retval;
@ -506,7 +507,7 @@ int FILE_INFO::parse(MIOFILE& in, bool from_server) {
}
strcat(signed_xml, buf);
if (parse_str(buf, "<name>", name, sizeof(name))) continue;
else if (parse_str(buf, "<url>", url.text, sizeof(url.text))) {
else if (parse_str(buf, "<url>", url)) {
urls.push_back(url);
continue;
}
@ -598,7 +599,7 @@ int FILE_INFO::write(MIOFILE& out, bool to_server) {
#endif
}
for (i=0; i<urls.size(); i++) {
out.printf(" <url>%s</url>\n", urls[i].text);
out.printf(" <url>%s</url>\n", urls[i].c_str());
}
if (!to_server && pers_file_xfer) {
retval = pers_file_xfer->write(out);
@ -692,7 +693,7 @@ char* FILE_INFO::get_init_url(bool is_upload) {
}
} else {
start_url = current_url;
return urls[current_url].text;
return urls[current_url].c_str();
}
}
}
@ -707,7 +708,7 @@ char* FILE_INFO::get_next_url(bool is_upload) {
return NULL;
}
if (is_correct_url_type(is_upload, urls[current_url])) {
return urls[current_url].text;
return urls[current_url].c_str();
}
}
}
@ -716,14 +717,14 @@ char* FILE_INFO::get_current_url(bool is_upload) {
if (current_url < 0) {
return get_init_url(is_upload);
}
return urls[current_url].text;
return urls[current_url].c_str();
}
// Checks if the url includes the phrase "file_upload_handler"
// The inclusion of this phrase indicates the url is an upload url
// Checks if the URL includes the phrase "file_upload_handler"
// This indicates the URL is an upload url
//
bool FILE_INFO::is_correct_url_type(bool is_upload, STRING256 url) {
char* has_str = strstr(url.text, "file_upload_handler");
bool FILE_INFO::is_correct_url_type(bool is_upload, std::string& url) {
char* has_str = strstr(url.c_str(), "file_upload_handler");
if ((is_upload && !has_str) || (!is_upload && has_str)) {
return false;
} else {

View File

@ -42,10 +42,6 @@
#define P_MEDIUM 3
#define P_HIGH 5
struct STRING256 {
char text[256];
};
// If the status is neither of these two,
// it will be an error code defined in error_numbers.h,
// indicating an unrecoverable error in the upload or download of the file,
@ -77,7 +73,7 @@ public:
struct RESULT* result; // for upload files (to authenticate)
class PROJECT* project;
int ref_cnt;
std::vector<STRING256> urls;
std::vector<std::string> urls;
int start_url;
int current_url;
char signed_xml[MAX_BLOB_LEN];
@ -109,7 +105,7 @@ public:
char* get_init_url(bool);
char* get_next_url(bool);
char* get_current_url(bool);
bool is_correct_url_type(bool, STRING256);
bool is_correct_url_type(bool, std::string&);
bool had_failure(int& failnum, char* buf=0);
bool verify_existing_file();
int merge_info(FILE_INFO&);
@ -170,7 +166,8 @@ public:
// They may depend on the host as well as user and project
// NOTE: if you add anything, add it to copy_state_fields() also!!!
//
std::vector<STRING256> scheduler_urls; // where to find scheduling servers
std::vector<std::string> scheduler_urls;
// where to find scheduling servers
char project_name[256]; // descriptive. not unique
char user_name[256];
char team_name[256];

View File

@ -274,7 +274,6 @@ int PROJECT::parse_preferences_for_user_files() {
string timestamp, open_name, url, filename;
FILE_INFO* fip;
FILE_REF fr;
STRING256 url_str;
char prefs_buf[MAX_BLOB_LEN];
strcpy(prefs_buf, project_specific_prefs.c_str());
p = prefs_buf;
@ -290,14 +289,13 @@ int PROJECT::parse_preferences_for_user_files() {
if (!parse_str(buf, "<timestamp>", timestamp)) break;
if (!parse_str(buf, "<open_name>", open_name)) break;
if (!parse_str(buf, "<url>", url)) break;
strcpy(url_str.text, url.c_str());
filename = open_name + "_" + timestamp;
fip = gstate.lookup_file_info(this, filename.c_str());
if (!fip) {
fip = new FILE_INFO;
fip->project = this;
fip->urls.push_back(url_str);
fip->urls.push_back(url);
strcpy(fip->name, filename.c_str());
fip->is_user_file = true;
gstate.file_infos.push_back(fip);

View File

@ -696,7 +696,7 @@ int CLIENT_STATE::handle_scheduler_reply(
}
}
for (i=0; i<sr.file_deletes.size(); i++) {
fip = lookup_file_info(project, sr.file_deletes[i].text);
fip = lookup_file_info(project, sr.file_deletes[i].c_str());
if (fip) {
msg_printf(project, MSG_INFO, "Got server request to delete file %s\n", fip->name);
fip->marked_for_delete = true;

View File

@ -263,30 +263,11 @@ int SCHEDULER_OP::init_master_fetch(PROJECT* p) {
return 0;
}
static void trim(STRING256& str) {
char* last_char = str.text + strlen(str.text);
while (isspace(*(last_char-1)) && last_char > str.text) {
--last_char;
}
*last_char = '\0';
char *first_char = str.text;
if (isspace(*first_char)) {
while (isspace(*first_char)) {
++first_char;
}
char* dest = str.text;
while (*first_char) {
*dest++ = *first_char++;
}
*dest = '\0';
}
}
// parse a master file.
//
int SCHEDULER_OP::parse_master_file(vector<STRING256> &urls) {
int SCHEDULER_OP::parse_master_file(vector<std::string> &urls) {
char buf[256];
STRING256 str;
std::string str;
FILE* f;
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
@ -298,8 +279,8 @@ int SCHEDULER_OP::parse_master_file(vector<STRING256> &urls) {
}
project->scheduler_urls.clear();
while (fgets(buf, 256, f)) {
if (parse_str(buf, "<scheduler>", str.text, sizeof(str.text))) {
trim(str);
if (parse_str(buf, "<scheduler>", str)) {
strip_whitespace(str);
urls.push_back(str);
}
}
@ -316,10 +297,10 @@ int SCHEDULER_OP::parse_master_file(vector<STRING256> &urls) {
}
// A master file has just been read.
// transfer scheduler urls to project.
// transfer scheduler URLs to project.
// Return true if any of them is new
//
bool SCHEDULER_OP::update_urls(vector<STRING256> &urls) {
bool SCHEDULER_OP::update_urls(vector<std::string> &urls) {
unsigned int i, j;
bool found, any_new;
@ -327,7 +308,7 @@ bool SCHEDULER_OP::update_urls(vector<STRING256> &urls) {
for (i=0; i<urls.size(); i++) {
found = false;
for (j=0; j<project->scheduler_urls.size(); j++) {
if (!strcmp(urls[i].text, project->scheduler_urls[i].text)) {
if (urls[i] == project->scheduler_urls[j]) {
found = true;
break;
}
@ -347,7 +328,7 @@ bool SCHEDULER_OP::update_urls(vector<STRING256> &urls) {
//
bool SCHEDULER_OP::poll() {
int retval, nresults;
vector<STRING256> urls;
vector<std::string> urls;
bool changed, scheduler_op_done;
bool action = false, err = false;
char err_msg[256], *err_url=NULL;
@ -442,7 +423,7 @@ bool SCHEDULER_OP::poll() {
if (log_flags.sched_ops) {
msg_printf(project, MSG_ERROR,
"Scheduler RPC to %s failed\n",
project->scheduler_urls[url_index].text
project->scheduler_urls[url_index].c_str()
);
}
@ -470,7 +451,7 @@ bool SCHEDULER_OP::poll() {
msg_printf(
project, MSG_INFO,
"Scheduler RPC to %s succeeded\n",
project->scheduler_urls[url_index].text
project->scheduler_urls[url_index].c_str()
);
}
retval = gstate.handle_scheduler_reply(project, scheduler_url, nresults);
@ -578,7 +559,7 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
char buf[256], msg_buf[1024], pri_buf[256];
int retval, x;
MIOFILE mf;
char delete_file_name[256];
std::string delete_file_name;
mf.init_file(in);
bool found_start_tag = false;
@ -734,10 +715,8 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
} else {
result_acks.push_back(result);
}
} else if (parse_str(buf, "<delete_file_info>", delete_file_name, sizeof(delete_file_name))) {
STRING256 delete_file;
strcpy(delete_file.text, delete_file_name);
file_deletes.push_back(delete_file);
} else if (parse_str(buf, "<delete_file_info>", delete_file_name)) {
file_deletes.push_back(delete_file_name);
} else if (parse_str(buf, "<message", msg_buf, sizeof(msg_buf))) {
parse_attr(buf, "priority", pri_buf, sizeof(pri_buf));
USER_MESSAGE um(msg_buf, pri_buf);

View File

@ -78,12 +78,12 @@ struct SCHEDULER_OP {
int init_op_project(double ns);
int init_master_fetch(PROJECT*);
int set_min_rpc_time(PROJECT*);
bool update_urls(std::vector<STRING256> &urls);
bool update_urls(std::vector<std::string> &urls);
int start_op(PROJECT*);
bool check_master_fetch_start();
void backoff(PROJECT* p, const char *error_msg);
int start_rpc();
int parse_master_file(std::vector<STRING256>&);
int parse_master_file(std::vector<std::string>&);
};
struct USER_MESSAGE {
@ -106,7 +106,7 @@ struct SCHEDULER_REPLY {
unsigned int user_create_time;
std::vector<APP> apps;
std::vector<FILE_INFO> file_infos;
std::vector<STRING256> file_deletes;
std::vector<std::string> file_deletes;
std::vector<APP_VERSION> app_versions;
std::vector<WORKUNIT> workunits;
std::vector<RESULT> results;