app_versions;
diff --git a/db/db.h b/db/db.h
index 8a14eed487..d8d43727da 100644
--- a/db/db.h
+++ b/db/db.h
@@ -46,7 +46,7 @@ struct PROJECT {
//
struct PLATFORM {
int id;
- unsigned int create_time; // UNIX time of record creation
+ unsigned int create_time;
char name[256]; // Platform name (i.e. "sparc-sun-solaris2.7")
};
@@ -55,8 +55,8 @@ struct PLATFORM {
//
struct APP {
int id;
- unsigned int create_time; // UNIX time of record creation
- char name[256]; // application name (i.e. "setiathome_4.0"), preferably short
+ unsigned int create_time;
+ char name[256]; // application name, preferably short
int min_version; // don't use versions before this
char result_xml_template[MAX_BLOB_SIZE];
// if any workunits have dynamic results,
@@ -71,20 +71,20 @@ struct APP {
//
struct APP_VERSION {
int id;
- unsigned int create_time; // UNIX time of record creation
- int appid; // id of APP record associated with this APP_VERSION
- int version_num; // Version number
- int platformid; // id of PLATFORM record associated with this APP_VERSION
+ unsigned int create_time;
+ int appid;
+ int version_num;
+ int platformid;
- // describes app files. format:
- // ...
- // ...
- //
- // ...
- // ...
- //
- //
char xml_doc[MAX_BLOB_SIZE];
+ // describes app files. format:
+ // ...
+ // ...
+ //
+ // ...
+ // ...
+ //
+ //
// The following defined for apps other than core client.
// They let you handle backwards-incompatible changes to
@@ -105,50 +105,49 @@ struct APP_VERSION {
struct USER {
int id;
- unsigned int create_time; // UNIX time of record creation
- char email_addr[256]; // User email address
- char name[256]; // User name
- char web_password[256]; // User specifiable web password
- char authenticator[256]; // Authenticator string, used to confirm email
- // address when signing up for a project
- char country[256]; // User country (selected from a list in countries.C)
- char postal_code[256]; // User postal code
+ unsigned int create_time;
+ char email_addr[256];
+ char name[256];
+ char web_password[256];
+ char authenticator[256];
+ char country[256];
+ char postal_code[256];
double total_credit;
- double expavg_credit; // exponenially averaged credit
- int expavg_time; // last time the above was computed
- char prefs[MAX_BLOB_SIZE]; // Raw XML preferences data
+ double expavg_credit; // exponentially averaged credit
+ int expavg_time; // last time the above was computed
+ char prefs[MAX_BLOB_SIZE]; // XML preferences
unsigned int prefs_mod_time; // When the preferences were last updated
- int teamid; //if the user is part of a team
+ int teamid; // if the user is part of a team
};
-#define TEAM_TYPE_COMPANY_SMALL 1
-#define TEAM_TYPE_COMPANY_MEDIUM 2
-#define TEAM_TYPE_COMPANY_LARGE 3
-#define TEAM_TYPE_CLUB 4
-#define TEAM_TYPE_PRIMARY 5
-#define TEAM_TYPE_SECONDARY 6
-#define TEAM_TYPE_UNIVERSITY 7
-#define TEAM_TYPE_JUNIOR_COLLEGE 8
-#define TEAM_TYPE_GOVERNMENT 9
+#define TEAM_TYPE_COMPANY_SMALL 1
+#define TEAM_TYPE_COMPANY_MEDIUM 2
+#define TEAM_TYPE_COMPANY_LARGE 3
+#define TEAM_TYPE_CLUB 4
+#define TEAM_TYPE_PRIMARY 5
+#define TEAM_TYPE_SECONDARY 6
+#define TEAM_TYPE_UNIVERSITY 7
+#define TEAM_TYPE_JUNIOR_COLLEGE 8
+#define TEAM_TYPE_GOVERNMENT 9
struct TEAM {
int id;
int userid; // User ID of team founder
- char name[256]; // Team name
+ char name[256];
char name_lc[256]; // Team name in lowercase (used for searching)
- char url[256]; // URL of team
- int type; // Team type (company, club, etc, see above definitions)
- char name_html[256]; //
+ char url[256];
+ int type; // Team type (see above)
+ char name_html[256];
char description[256];
int nusers;
};
struct HOST {
int id;
- unsigned int create_time; // UNIX time of record creation
+ unsigned int create_time;
int userid; // ID of user running this host
int rpc_seqno; // last seqno received from client
- unsigned int rpc_time; // UNIX time of last scheduler RPC
+ unsigned int rpc_time; // time of last scheduler RPC
// all remaining items are assigned by the client
int timezone;
@@ -159,28 +158,28 @@ struct HOST {
double on_frac; // Fraction of the time (0-1) that the host is on
double connected_frac; // Fraction of time that host is connected
- double active_frac; // Fraction of time that host is actively doing tasks
+ double active_frac; // Fraction of time that host is enabled to work
int p_ncpus; // Number of CPUs on host
- char p_vendor[256]; // Vendor name of host CPU
- char p_model[256]; // Model of host CPU
- double p_fpops; // Approximate flop speed of host CPU
- double p_iops; // Approximate integer op/sec speed of host CPU
- double p_membw; // Approximate memory bandwidth of host
+ char p_vendor[256]; // Vendor name of CPU
+ char p_model[256]; // Model of CPU
+ double p_fpops; // Approximate floating point speed of CPU
+ double p_iops; // Approximate integer op/sec speed of CPU
+ double p_membw; // Approximate memory bandwidth of CPU
double p_calculated;
- char os_name[256]; // Name of host operating system
- char os_version[256]; // Version of host operating system
+ char os_name[256]; // Name of operating system
+ char os_version[256]; // Version of operating system
- double m_nbytes; // Size of host memory in bytes
+ double m_nbytes; // Size of memory in bytes
double m_cache; // Size of CPU cache in bytes (L1 or L2?)
- double m_swap; // Size of host swap space in bytes
+ double m_swap; // Size of swap space in bytes
double d_total; // Total disk space
double d_free;
- double n_bwup; // Average upload bandwidth for host
- double n_bwdown; // Average download bandwidth for host
+ double n_bwup; // Average upload bandwidth
+ double n_bwdown; // Average download bandwidth
int parse(FILE*);
int parse_time_stats(FILE*);
@@ -189,20 +188,20 @@ struct HOST {
struct WORKUNIT {
int id;
- unsigned int create_time; // UNIX time of record creation
+ unsigned int create_time; // time of record creation
int appid; // ID of APP record tied to this workunit
int previous_wuid;
bool has_successor;
char name[256]; // Name of the workunit
char xml_doc[MAX_BLOB_SIZE];
int batch;
- double rsc_fpops; // estimated # of FP operations
- double rsc_iops; // estimated # of integer operations
- double rsc_memory; // estimated size of RAM working set (bytes)
- double rsc_disk; // estimated amount of disk needed (bytes)
+ double rsc_fpops; // estimated # of FP operations
+ double rsc_iops; // estimated # of integer operations
+ double rsc_memory; // estimated size of RAM working set (bytes)
+ double rsc_disk; // estimated amount of disk needed (bytes)
bool dynamic_results;
// whether to create new results on demand
- int max_results; // 0 if no limit
+ int max_results; // 0 if no limit
int nresults;
int nresults_unsent;
int nresults_done;
@@ -221,16 +220,16 @@ struct WORKUNIT {
struct RESULT {
int id;
- unsigned int create_time; // UNIX time of record creation
- int workunitid; // ID of the workunit tied to this result
- int state; // Current state of the processing for this result
- int hostid; // ID of host currently processing this result
- unsigned int report_deadline; // UNIX time deadline for receiving result
- unsigned int sent_time; // UNIX time that result request was sent to host
- unsigned int received_time; // UNIX time that result data was received from host
- char name[256]; // Name of result
- int exit_status; // Final exit status of application that processed result
- double cpu_time; // Total CPU time required to complete result
+ unsigned int create_time;
+ int workunitid;
+ int state; // state (see above)
+ int hostid; // host processing this result
+ unsigned int report_deadline; // deadline for receiving result
+ unsigned int sent_time; // when result was sent to host
+ unsigned int received_time; // when result was received from host
+ char name[256];
+ int exit_status;
+ double cpu_time; // CPU time used to complete result
char xml_doc_in[MAX_BLOB_SIZE]; // descriptions of output files
char xml_doc_out[MAX_BLOB_SIZE]; // MD5s of output files
char stderr_out[MAX_BLOB_SIZE]; // stderr output, if any
diff --git a/html/ops/db.inc b/html/ops/db.inc
new file mode 100644
index 0000000000..6992f9a1b2
--- /dev/null
+++ b/html/ops/db.inc
@@ -0,0 +1,172 @@
+id);
+ row("created", time_str($platform->create_time));
+ row("name", $platform->name);
+ echo "";
+}
+
+function show_app($app) {
+ start_table();
+ row("ID", $app->id);
+ row("created", time_str($app->create_time));
+ row("name", $app->name);
+ row("result template", "".htmlspecialchars($app->result_xml_template)."
");
+ echo "";
+}
+
+function show_app_version($app_version) {
+ start_table();
+ row("ID", $app_version->id);
+ row("created", time_str($app_version->create_time));
+ row("app ID", $app_version->appid);
+ row("version num", $app_version->version_num);
+ row("platform ID", $app_version->platformid);
+ row("XML doc", "".htmlspecialchars($app_version->xml_doc)."
");
+ row("min_core_version", $app_version->min_core_version);
+ row("max_core_version", $app_version->max_core_version);
+ row("message", $app_version->message);
+ row("deprecated", $app_version->deprecated);
+ echo "";
+}
+
+function show_host($host) {
+
+ echo TABLE2."\n";
+ echo "Below is information on all the hosts you have running the BOINC core client.";
+ echo "";
+ echo "
".TD2.LG_FONT."Host Information:
\n";
+ row("IP address: ", "$host->last_ip_addr
(same the last $host->nsame_ip_addr times)");
+ row("Domain name: ", $host->domain_name);
+ $x = $host->timezone/3600;
+ row("Time zone: ", "UTC - $x hours");
+ row("Created: ", time_str($host->create_time));
+ row("CPU: ", "$host->p_vendor $host->p_model");
+ row("Number of CPUs: ", $host->p_ncpus);
+ row("Operating System: ", "$host->os_name $host->os_version");
+ $x = $host->m_nbytes/(1024*1024);
+ $y = round($x, 2);
+ row("Memory: ", "$y MB");
+ $x = $host->m_cache/1024;
+ $y = round($x, 2);
+ row("Cache: ", "$y KB");
+ $x = $host->m_swap/(1024*1024);
+ $y = round($x, 2);
+ row("Swap Space: ", "$y MB");
+ $x = $host->d_total/(1024*1024*1024);
+ $y = round($x, 2);
+ row("Total Disk Space: ", "$y GB");
+ $x = $host->d_free/(1024*1024*1024);
+ $y = round($x, 2);
+ row("Free Disk Space: ", "$y GB");
+ row("Avg network bandwidth:
(upstream) ", "$host->n_bwup bytes/sec");
+ row("Avg network bandwidth:
(downstream) ", "$host->n_bwdown bytes/sec");
+ row("Number of times client has contacted server: ", $host->rpc_seqno);
+ row("Last time contacted server: ", time_str($host->rpc_time));
+ row("% of time client on: ", 100*$host->on_frac." %");
+ row("% of time host connected: ", 100*$host->connected_frac." %");
+ row("% of time user active: ", 100*$host->active_frac." %");
+ echo "\n";
+
+}
+
+function show_workunit($wu) {
+ start_table();
+ row("created", time_str($wu->create_time));
+ row("name", $wu->name);
+ row("XML doc", "".htmlspecialchars($wu->xml_doc)."
");
+ row("app ID", $wu->appid);
+ row("batch", $wu->batch);
+ row("FP operations", $wu->rsc_fpops);
+ row("integer operations", $wu->rsc_iops);
+ row("memory requirement", $wu->rsc_memory);
+ row("disk requirement", $wu->rsc_disk);
+ row("dynamic results", $wu->dynamic_results?"yes":"no");
+ row("max_results", $wu->max_results);
+ row("nresults", $wu->nresults);
+ row("nresults_unsent", $wu->nresults_unsent);
+ row("nresults_done", $wu->nresults_done);
+ row("nresults_fail", $wu->nresults_fail);
+ echo "";
+}
+
+function res_state_string($s) {
+ switch($s) {
+ case 1: return "inactive";
+ case 2: return "unsent";
+ case 3: return "in progress";
+ case 4: return "done";
+ case 5: return "timeout";
+ case 6: return "error";
+ }
+}
+
+function show_result($result) {
+ start_table();
+ row("created", time_str($result->create_time));
+ row("name", $result->name);
+ row("workunit ID", $result->workunitid);
+ row("state", res_state_string($result->state));
+ row("host ID", $result->hostid);
+ row("sent", time_str($result->sent_time));
+ row("received", time_str($result->received_time));
+ row("exit status", $result->exit_status);
+ row("CPU time", $result->cpu_time);
+ row("XML doc in", "".htmlspecialchars($result->xml_doc_in)."
");
+ row("XML doc out", "".htmlspecialchars($result->xml_doc_out)."
");
+ row("stderr out", "".htmlspecialchars($result->stderr_out)."
");
+ row("batch", $result->batch);
+ row("validated", $result->validated);
+ echo "";
+}
+
+function show_user($user) {
+ start_table();
+ row("created", time_str($user->create_time));
+ row("total credit", $user->total_credit);
+ row("recent averaged credit:", $user->expavg_credit);
+ row("name", $user->name);
+ row("email address", $user->email_addr);
+ row("country", $user->country);
+ row("postal code", $user->postal_code);
+ echo "\n";
+}
+
+function show_team($team) {
+ start_table();
+ row("ID", $team->id);
+ row("founder", $team->userid);
+ row("name", $team->name);
+ row("url", $team->url);
+ row("type", $team->type);
+ row("name_html", $team->name_html);
+ row("description", $team->description);
+}
+
+?>
diff --git a/html/ops/util.inc b/html/ops/util.inc
new file mode 100644
index 0000000000..aa299bab58
--- /dev/null
+++ b/html/ops/util.inc
@@ -0,0 +1,111 @@
+");
+define("SM_FONT", "");
+
+define("TD", "");
+define("TD2", " | ");
+define("TD3", " | ");
+
+define("TABLE", "");
+define("TABLE2", "");
+
+define("BG_COLOR", " bgcolor=cccccc ");
+define("TITLE_COLOR", " bgcolor=000000 ");
+define("TITLE_FONT", " ");
+define("BODY_COLOR", " bgcolor=ffffff ");
+define("NOLOGIN", "Not logged in. Click here to login.\n");
+define("BADPASS", "The password you entered is incorrect. Click the Back button on your browser to re-enter your password or try again later.");
+define("DIFFPASS", "You've typed two different passwords. Click the Back button on your browser to edit your information, making sure you type the same password in both password fields.");
+
+function get_project_name() {
+ $fp = fopen(db_name, "r");
+ $db_name = fgets($fp, 1024);
+ $db_name = rtrim($db_name);
+ return $db_name;
+}
+
+function get_user_from_cookie() {
+ $auth = "";
+ $c = getenv("HTTP_COOKIE");
+ $d = str_replace("; ", "&", $c);
+ parse_str($d);
+ if ($auth) return lookup_user_auth($auth);
+ return NULL;
+}
+
+function show_login($user) {
+ if ($user) {
+ printf("Logged in as %s.\n", $user->name);
+ printf(" Log in as someone else.\n");
+ $project = get_project_name();
+ printf(" My %s\n", $project);
+ } else {
+ echo NOLOGIN;
+ }
+}
+
+function page_head($title) {
+ echo "$title\n";
+ $project = get_project_name();
+ echo TABLE . "" . TITLE_FONT . "".$project.": $title | \n";
+}
+
+function page_tail() {
+ echo " \n";
+}
+
+function date_str($when) {
+ return date("g:i A, l M j", $when);
+}
+
+function time_str($x) {
+ if ($x == 0) return "---";
+ return strftime("%T %b %e, %Y", $x);
+}
+
+function start_table() {
+ echo "";
+}
+
+function row($x, $y) {
+ echo "$x | $y | \n";
+}
+
+function row2($x, $y) {
+ echo "$x | $y | \n";
+}
+
+function row3($x, $y, $z) {
+ echo "$x | $y | $z | \n";
+}
+
+function random_string() {
+ return md5(uniqid(rand()));
+}
+
+function print_country_select() {
+ PassThru("/disks/milkyway/a/users/anderson/boinc/tools/country_select");
+}
+
+function print_page_header($title) {
+ echo "\n";
+ echo "\n";
+ echo "$title\n";
+ echo "\n";
+ echo "\n";
+ echo "
\n";
+}
+
+function print_page_end() {
+ echo "";
+}
+
+?>
diff --git a/lib/crypt_prog.C b/lib/crypt_prog.C
index 449639efbe..da19404b12 100644
--- a/lib/crypt_prog.C
+++ b/lib/crypt_prog.C
@@ -39,6 +39,7 @@ main(int argc, char** argv) {
exit(1);
}
if (!strcmp(argv[1], "-genkey")) {
+ printf("creating keys in %s and %s\n", argv[3], argv[4]);
n = atoi(argv[2]);
R_RandomCreate(&randomStruct);
@@ -50,7 +51,6 @@ main(int argc, char** argv) {
);
if (retval) die("R_GeneratePEMKeys\n");
- printf("creating keys in %s and %s\n", argv[3], argv[4]);
fpriv = fopen(argv[3], "w");
if (!fpriv) die("fopen");
fpub = fopen(argv[4], "w");
diff --git a/sched/file_upload_handler.C b/sched/file_upload_handler.C
index 5e6ce88376..a17e4a0349 100644
--- a/sched/file_upload_handler.C
+++ b/sched/file_upload_handler.C
@@ -71,7 +71,7 @@ int FILE_INFO::parse(FILE* in) {
strcatdup(signed_xml, buf);
if (parse_str(buf, "", name)) continue;
if (parse_double(buf, "", max_nbytes)) continue;
- //fprintf(stderr, "file_upload_handler: FILE_INFO::parse: unrecognized: %s \n", buf);
+ //fprintf(stderr, "file_upload_handler (%s): FILE_INFO::parse: unrecognized: %s \n", BOINC_USER, buf);
}
return 1;
}
@@ -79,10 +79,10 @@ int FILE_INFO::parse(FILE* in) {
int print_status(int status, char* message) {
printf("Content-type: text/plain\n\n%d\n", status);
if (message) printf("%s\n", message);
-#if 0
- fprintf(stderr, "Content-type: text/plain\n\n%d\n", status);
- if (message) fprintf(stderr, "%s\n", message);
-#endif
+ fprintf(stderr,
+ "file_upload_handler (%s): status %d: %s>\n",
+ BOINC_USER, status, message
+ );
return 0;
}
@@ -145,14 +145,16 @@ int handle_request(FILE* in, R_RSA_PUBLIC_KEY& key) {
if (match_tag(buf, "")) {
retval = file_info.parse(in);
if (retval) {
- fprintf(stderr, "file_upload_handler: FILE_INFO.parse\n");
+ fprintf(stderr,
+ "file_upload_handler (%s): FILE_INFO.parse\n",
+ BOINC_USER
+ );
return retval;
}
retval = verify_string(
file_info.signed_xml, file_info.xml_signature, key, is_valid
);
if (retval || !is_valid) {
- fprintf(stderr, "invalid XML signature\n");
print_status(-1, "invalid XML signature");
return -1;
}
@@ -175,14 +177,12 @@ int handle_request(FILE* in, R_RSA_PUBLIC_KEY& key) {
else if (parse_double(buf, "", nbytes)) continue;
else if (match_tag(buf, "")) {
if (nbytes == 0) {
- fprintf(stderr, "nbytes missing\n");
print_status(-1, "nbytes missing");
return -1;
}
// enforce limits in signed XML
if (nbytes > file_info.max_nbytes) {
- fprintf(stderr, "nbytes too large\n");
sprintf(buf,
"nbytes too large: %f > %f",
nbytes, file_info.max_nbytes
@@ -193,8 +193,11 @@ int handle_request(FILE* in, R_RSA_PUBLIC_KEY& key) {
sprintf(path, "%s/%s", BOINC_UPLOAD_DIR, file_info.name);
retval = copy_socket_to_file(in, path, offset, nbytes);
- if(retval) {
- fprintf(stderr, "file_upload_handler: copy_socket_to_file\n");
+ if (retval) {
+ fprintf(stderr,
+ "file_upload_handler (%s): copy_socket_to_file %d %s\n",
+ BOINC_USER, retval, path
+ );
}
break;
}
diff --git a/sched/handle_request.C b/sched/handle_request.C
index 6a98b4f282..e8fa357814 100644
--- a/sched/handle_request.C
+++ b/sched/handle_request.C
@@ -97,25 +97,23 @@ int add_wu_to_reply(
// If no host ID is supplied, or if RPC seqno mismatch,
// create a new host record and return its ID
//
-int authenticate_user(
- SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, USER& user, HOST& host
-) {
+int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
int retval;
if (sreq.hostid) {
- retval = db_host(sreq.hostid, host);
+ retval = db_host(sreq.hostid, reply.host);
if (retval) {
strcpy(reply.message, "Can't find host record");
strcpy(reply.message_priority, "low");
return -1;
}
- retval = db_user(host.userid, user);
+ retval = db_user(reply.host.userid, reply.user);
if (retval) {
strcpy(reply.message, "Can't find user record");
strcpy(reply.message_priority, "low");
return -1;
}
- if (strcmp(sreq.authenticator, user.authenticator)) {
+ if (strcmp(sreq.authenticator, reply.user.authenticator)) {
strcpy(reply.message,
"Invalid or missing authenticator. "
"Visit this project's web site to get an authenticator."
@@ -127,36 +125,39 @@ int authenticate_user(
// If the seqno from the host is less than what we expect,
// the user must have copied the state file to a different host.
// Make a new host record.
- if (sreq.rpc_seqno < host.rpc_seqno) {
+ if (sreq.rpc_seqno < reply.host.rpc_seqno) {
sreq.hostid = 0;
goto new_host;
}
- host.rpc_seqno = sreq.rpc_seqno;
- host.rpc_time = time(0);
+ reply.host.rpc_seqno = sreq.rpc_seqno;
+ reply.host.rpc_time = time(0);
} else {
- strcpy(user.authenticator, sreq.authenticator);
- retval = db_user_lookup_auth(user);
+ strcpy(reply.user.authenticator, sreq.authenticator);
+ retval = db_user_lookup_auth(reply.user);
if (retval) {
strcpy(reply.message, "Invalid or missing authenticator");
strcpy(reply.message_priority, "low");
return -1;
}
new_host:
- host = sreq.host;
- host.id = 0;
- host.create_time = time(0);
- host.userid = user.id;
- host.rpc_seqno = 0;
- host.rpc_time = time(0);
- retval = db_host_new(host);
+ // reply.user is filled in and valid at this point
+ //
+ reply.host = sreq.host;
+ reply.host.id = 0;
+ reply.host.create_time = time(0);
+ reply.host.userid = reply.user.id;
+ reply.host.rpc_seqno = 0;
+ reply.host.rpc_time = time(0);
+ retval = db_host_new(reply.host);
if (retval) {
strcpy(reply.message, "server database error");
strcpy(reply.message_priority, "low");
db_print_error("db_host_new");
return -1;
}
- host.id = db_insert_id();
- reply.hostid = host.id;
+ reply.host.id = db_insert_id();
+ reply.hostid = reply.host.id;
+ // this tells client to updates its host ID
}
return 0;
}
@@ -205,16 +206,16 @@ int update_host_record(SCHEDULER_REQUEST& sreq, HOST& host) {
// update user record in DB.
// If we our DB has more recent prefs than client's, send them.
//
-int handle_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, USER& user) {
- if (sreq.prefs_mod_time > user.prefs_mod_time && strlen(sreq.prefs_xml)) {
- strcpy(user.prefs, sreq.prefs_xml);
- user.prefs_mod_time = sreq.prefs_mod_time;
- if (user.prefs_mod_time > (unsigned)time(0)) {
- user.prefs_mod_time = (unsigned)time(0);
+int handle_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
+ if (sreq.prefs_mod_time > reply.user.prefs_mod_time && strlen(sreq.prefs_xml)) {
+ strcpy(reply.user.prefs, sreq.prefs_xml);
+ reply.user.prefs_mod_time = sreq.prefs_mod_time;
+ if (reply.user.prefs_mod_time > (unsigned)time(0)) {
+ reply.user.prefs_mod_time = (unsigned)time(0);
}
- db_user_update(user);
+ db_user_update(reply.user);
}
- if (user.prefs_mod_time > sreq.prefs_mod_time) {
+ if (reply.user.prefs_mod_time > sreq.prefs_mod_time) {
reply.send_prefs = true;
}
return 0;
@@ -222,9 +223,7 @@ int handle_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, USER& user) {
// handle completed results
//
-int handle_results(
- SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, HOST& host
-) {
+int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
unsigned int i;
int retval;
RESULT result, *rp;
@@ -244,7 +243,7 @@ int handle_results(
// TODO: handle error returns
//
- result.hostid = host.id;
+ result.hostid = reply.host.id;
result.received_time = time(0);
result.exit_status = rp->exit_status;
result.cpu_time = rp->cpu_time;
@@ -276,7 +275,7 @@ int handle_results(
int send_work(
SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, PLATFORM& platform,
- HOST& host, SCHED_SHMEM& ss
+ SCHED_SHMEM& ss
) {
int i, retval, nresults = 0, seconds_to_fill;
WORKUNIT wu;
@@ -299,7 +298,7 @@ int send_work(
// the following should be a critical section
//
if (!ss.wu_results[i].present ||
- !wu_is_feasible(ss.wu_results[i].workunit, host)
+ !wu_is_feasible(ss.wu_results[i].workunit, reply.host)
) {
continue;
}
@@ -308,15 +307,15 @@ int send_work(
ss.wu_results[i].present = false;
retval = add_wu_to_reply(wu, reply, platform, ss,
- estimate_duration(wu, host)
+ estimate_duration(wu, reply.host)
);
if (retval) continue;
reply.insert_result(result);
- seconds_to_fill -= (int)estimate_duration(wu, host);
+ seconds_to_fill -= (int)estimate_duration(wu, reply.host);
nresults++;
result.state = RESULT_STATE_IN_PROGRESS;
- result.hostid = host.id;
+ result.hostid = reply.host.id;
result.sent_time = time(0);
db_result_update(result);
@@ -337,7 +336,7 @@ int send_work(
result.create_time = time(0);
result.workunitid = wu.id;
result.state = RESULT_STATE_IN_PROGRESS;
- result.hostid = host.id;
+ result.hostid = reply.host.id;
result.sent_time = time(0);
sprintf(result.name, "result_%d", result.id);
app = db.lookup_app(wu.appid);
@@ -415,16 +414,14 @@ void process_request(
SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, SCHED_SHMEM& ss,
char* code_sign_key
) {
- HOST host;
- USER user;
PLATFORM* platform;
int retval;
char buf[256];
- retval = authenticate_user(sreq, reply, user, host);
+ retval = authenticate_user(sreq, reply);
if (retval) return;
- retval = update_host_record(sreq, host);
+ retval = update_host_record(sreq, reply.host);
// look up the client's platform in the DB
//
@@ -436,13 +433,11 @@ void process_request(
return;
}
- reply.user = user;
+ handle_prefs(sreq, reply);
- handle_prefs(sreq, reply, user);
+ handle_results(sreq, reply);
- handle_results(sreq, reply, host);
-
- send_work(sreq, reply, *platform, host, ss);
+ send_work(sreq, reply, *platform, ss);
send_code_sign_key(sreq, reply, code_sign_key);
}
diff --git a/sched/server_types.C b/sched/server_types.C
index 6f03e6275b..b3aeecbb2f 100644
--- a/sched/server_types.C
+++ b/sched/server_types.C
@@ -114,7 +114,15 @@ int SCHEDULER_REPLY::write(FILE* fout) {
gproject.name
);
-
+ fprintf(fout,
+ "%s\n"
+ "%f\n"
+ "%f\n",
+ user.name,
+ user.total_credit,
+ user.expavg_credit
+ );
+
if (request_delay) {
fprintf(fout, "%d\n", request_delay);
}
diff --git a/sched/server_types.h b/sched/server_types.h
index 8b772d5fb9..bee9a1b2ca 100644
--- a/sched/server_types.h
+++ b/sched/server_types.h
@@ -52,6 +52,7 @@ struct SCHEDULER_REPLY {
// this tells client to reset rpc_seqno
bool send_prefs; // whether to send preferences
USER user;
+ HOST host;
vector apps;
vector app_versions;
vectorwus;
diff --git a/test/init.inc b/test/init.inc
index 44f6717ba4..28c2725d17 100644
--- a/test/init.inc
+++ b/test/init.inc
@@ -4,7 +4,6 @@ define("VERSION", "1");
define("CORE_CLIENT", "boinc_".VERSION."_$BOINC_PLATFORM");
define("PROJECTS", "localhost.localdomain zoot");
-include_once("../html_user/db.inc");
function clear_db() {
PassThru("cd ../db; init_db");
@@ -17,6 +16,22 @@ $BOINC_EMAIL = null;
$BOINC_DOWNLOAD_URL = null;
$BOINC_KEY_DIR = null;
$BOINC_MASTER_URL = null;
+$BOINC_DB_NAME = null;
+
+function open_db() {
+ global $BOINC_DB_NAME;
+
+ $retval = mysql_connect();
+ if (!$retval) {
+ echo "mysql_connect() failed\n";
+ exit();
+ }
+ $retval = mysql_select_db($BOINC_DB_NAME);
+ if (!$retval) {
+ echo "mysql_select_db() failed\n";
+ exit();
+ }
+}
function check_env_vars() {
global $BOINC_DOWNLOAD_DIR;
@@ -26,6 +41,7 @@ function check_env_vars() {
global $BOINC_DOWNLOAD_URL;
global $BOINC_KEY_DIR;
global $BOINC_MASTER_URL;
+ global $BOINC_DB_NAME;
$bad = false;
$BOINC_DOWNLOAD_DIR = getenv("BOINC_DOWNLOAD_DIR");
@@ -63,38 +79,47 @@ function check_env_vars() {
echo "Must define BOINC_MASTER_URL\n";
$bad = true;
}
+ $BOINC_DB_NAME = getenv("BOINC_DB_NAME");
+ if ($BOINC_DB_NAME == null) {
+ echo "Must define BOINC_DB_NAME\n";
+ $bad = true;
+ }
if ($bad) exit();
}
-function clear_data_dirs() {
+function clear_server_dirs($clear_key_dir) {
global $BOINC_DOWNLOAD_DIR;
global $BOINC_UPLOAD_DIR;
+ global $BOINC_KEY_DIR;
- $BOINC_DOWNLOAD_DIR = getenv("BOINC_DOWNLOAD_DIR");
if ($BOINC_DOWNLOAD_DIR == null) {
echo "Must define BOINC_DOWNLOAD_DIR\n";
$bad = true;
}
- $BOINC_UPLOAD_DIR = getenv("BOINC_UPLOAD_DIR");
if ($BOINC_UPLOAD_DIR == null) {
echo "Must define BOINC_UPLOAD_DIR\n";
$bad = true;
}
- $BOINC_KEY_DIR = getenv("BOINC_KEY_DIR");
if ($BOINC_KEY_DIR == null) {
echo "Must define BOINC_KEY_DIR\n";
$bad = true;
}
- $MASTER_URL = urlencode(stripslashes(stripslashes(getenv("BOINC_MASTER_URL"))));
- if ($MASTER_URL == null) {
- echo "Must define BOINC_MASTER_URL\n";
- $bad = true;
- }
if ($bad) exit();
PassThru("rm -f $BOINC_DOWNLOAD_DIR/*");
PassThru("rm -f $BOINC_UPLOAD_DIR/*");
- PassThru("rm -f $BOINC_KEY_DIR/*");
+ if ($clear_key_dir) {
+ PassThru("rm -f $BOINC_KEY_DIR/*");
+ }
+}
+
+function clear_client_dirs() {
+ $MASTER_URL = urlencode(stripslashes(stripslashes(getenv("BOINC_MASTER_URL"))));
+ if ($MASTER_URL == null) {
+ echo "Must define BOINC_MASTER_URL\n";
+ $bad = true;
+ }
+ if ($bad) exit();
PassThru("rm -f $MASTER_URL/*" );
}
@@ -230,7 +255,7 @@ function compare_file($out, $correct) {
}
function check_results_done() {
- db_init();
+ open_db();
$result = mysql_query("select * from result where state<>4");
while ($x = mysql_fetch_object($result)) {
echo "result $x->id is not done\n";
@@ -238,7 +263,7 @@ function check_results_done() {
}
function num_wus_left() {
- db_init();
+ open_db();
$numwus = mysql_query("select count(*) as nres from result where state<>4");
$result = mysql_fetch_object($numwus);
return $result->nres;
@@ -271,7 +296,7 @@ function get_time($file_name) {
function compare_time($app_time) {
$epsilon = 0.0001;
- db_init();
+ open_db();
$data = mysql_query("select cpu_time from result where name = 'uccpu_wu_0'");
$result = mysql_fetch_object($data);
$db_time = $result->cpu_time;
diff --git a/test/master.html b/test/master.html
index 60044e2e7a..2f57a59f15 100644
--- a/test/master.html
+++ b/test/master.html
@@ -1,3 +1,16 @@
-Test BOINC Project
-
-http://localhost/boinc-cgi/cgi
+
+BOINC Test Project
+
+
+BOINC Test Project
+
+
+
+
diff --git a/test/test_uc.php b/test/test_uc.php
index fe6fb34218..9bd5528719 100644
--- a/test/test_uc.php
+++ b/test/test_uc.php
@@ -8,8 +8,13 @@
check_env_vars();
clear_db();
- clear_data_dirs();
- create_keys();
+ if (true) {
+ clear_server_dirs(false);
+ } else {
+ clear_server_dirs(true);
+ create_keys();
+ }
+ clear_client_dirs();
init_client_dirs("prefs1.xml");
copy_to_download_dir("input");
add_project("Test Project");
@@ -18,8 +23,8 @@
add_app("upper_case", null, null);
create_work("-appname upper_case -rsc_iops 180000000000.0 -rsc_fpops 0.0 -wu_name uc_wu -wu_template uc_wu -result_template uc_result -nresults 2 input input input input input");
start_feeder();
- //run_client("-exit_after 10");
- run_client("-exit_when_idle");
+ run_client("-exit_after 10");
+ //run_client("-exit_when_idle");
stop_feeder();
check_results_done();
compare_file("uc_wu_0_0", "uc_correct_output");
|