From 00191f0456e274ff1f2224717c19fdaea5d7a543 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 30 Apr 2004 18:26:20 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=3308 --- checkin_notes | 16 ++++++++++++ html/inc/db.inc | 4 +-- html/user/create_account_action.php | 2 +- sched/handle_request.C | 9 +++++++ sched/main.C | 39 +++++++++++++++++------------ sched/main.h | 3 +++ sched/server_types.C | 2 ++ sched/server_types.h | 1 + 8 files changed, 57 insertions(+), 19 deletions(-) diff --git a/checkin_notes b/checkin_notes index ebd4b63e77..be36783280 100755 --- a/checkin_notes +++ b/checkin_notes @@ -11842,3 +11842,19 @@ Rom April 28 2004 win_build/ boinc_cli.vcproj +David April 30 2004 + - scheduler: connect to DB after checking major version# + - scheduler: request 24-hour delay if bad major version# + - scheduler: request 1 hr delay if project is shut down + - scheduler: parse from client + - print expanded error in PHP when can't connect to DB + + html/ + inc/ + db.inc + user/ + create_account_action.php + sched/ + handle_request.C + main.C,h + server_types.C,h diff --git a/html/inc/db.inc b/html/inc/db.inc index a44f5bd0ac..fa0798514d 100644 --- a/html/inc/db.inc +++ b/html/inc/db.inc @@ -14,8 +14,8 @@ function db_init() { $pass = parse_config(""); $retval = mysql_pconnect("localhost", $user, $pass); if (!$retval) { - echo "Unable to connect to database - please try again later"; - echo mysql_error(); + echo "Unable to connect to database - please try again later\n"; + echo "Error: ", mysql_errno(), mysql_error(); exit(); } $db_name = parse_config(""); diff --git a/html/user/create_account_action.php b/html/user/create_account_action.php index 3ad673f81a..4d9a9402f2 100644 --- a/html/user/create_account_action.php +++ b/html/user/create_account_action.php @@ -67,7 +67,7 @@ function show_error($str) { $cross_project_id = random_string(); $munged_email_addr = munge_email_addr($new_email_addr, $authenticator); $query = sprintf( - "insert into user (create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, url, send_email, show_hosts, cross_project_id) values(%d, '%s', '%s', '%s', '%s', '%s', 0, 0, 0, '$project_prefs', $teamid, 'home', '', 1, 1, $cross_project_id)", + "insert into user (create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, url, send_email, show_hosts, cross_project_id) values(%d, '%s', '%s', '%s', '%s', '%s', 0, 0, 0, '$project_prefs', $teamid, 'home', '', 1, 1, '$cross_project_id')", time(), $munged_email_addr, $new_name, diff --git a/sched/handle_request.C b/sched/handle_request.C index 02e54edc9b..3f4fff2903 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -490,6 +490,7 @@ bool wrong_major_version(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { sreq.hostid, sreq.authenticator, MAJOR_VERSION, sreq.core_client_major_version ); + reply.request_delay = 3600*24; return true; } return false; @@ -567,6 +568,14 @@ void process_request( // if (wrong_major_version(sreq, reply)) return; + // now open the database + // + retval = open_database(); + if (retval) { + send_shut_message(); + return; + } + retval = authenticate_user(sreq, reply); if (retval) return; if (reply.user.id == 0) { diff --git a/sched/main.C b/sched/main.C index 6401c6f170..510fa30679 100644 --- a/sched/main.C +++ b/sched/main.C @@ -33,6 +33,7 @@ using namespace std; #include "boinc_db.h" #include "parse.h" #include "filesys.h" +#include "error_numbers.h" #include "shmem.h" #include "util.h" @@ -64,10 +65,32 @@ void send_shut_message() { "Content-type: text/plain\n\n" "\n" " Project is temporarily shut down for maintenance\n" + " 3600\n" "\n" ); } +int open_database() { + int retval; + bool found; + + retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); + if (retval) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't open database\n"); + return retval; + } else { + found = false; + while (!gproject.enumerate("")) { + found = true; + } + if (!found) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't find project\n"); + return ERR_DB_NOT_FOUND; + } + } + return 0; +} + int main() { FILE* fin, *fout; int i, retval, pid; @@ -76,7 +99,6 @@ int main() { void* p; unsigned int counter=0; char* code_sign_key; - bool found; bool project_stopped = false; get_log_path(path); @@ -137,21 +159,6 @@ int main() { } } - retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd); - if (retval) { - log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't open database\n"); - project_stopped = true; - } else { - found = false; - while (!gproject.enumerate("")) { - found = true; - } - if (!found) { - log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't find project\n"); - exit(1); - } - } - pid = getpid(); #ifdef _USING_FCGI_ while(FCGI_Accept() >= 0) { diff --git a/sched/main.h b/sched/main.h index d92d2f6fda..98d890af49 100644 --- a/sched/main.h +++ b/sched/main.h @@ -24,3 +24,6 @@ extern DB_PROJECT gproject; extern SCHED_CONFIG config; extern key_t sema_key; + +extern void send_shut_message(); +extern int open_database(); diff --git a/sched/server_types.C b/sched/server_types.C index fb6e7c9c68..83ca3511d1 100644 --- a/sched/server_types.C +++ b/sched/server_types.C @@ -68,6 +68,7 @@ int SCHEDULER_REQUEST::parse(FILE* fin) { while (fgets(buf, 256, fin)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", authenticator, sizeof(authenticator))) continue; + else if (parse_str(buf, "", cross_project_id, sizeof(cross_project_id))) continue; else if (parse_int(buf, "", hostid)) continue; else if (parse_int(buf, "", rpc_seqno)) continue; else if (parse_str(buf, "", platform_name, sizeof(platform_name))) continue; @@ -184,6 +185,7 @@ int SCHEDULER_REPLY::write(FILE* fout) { if (request_delay) { fprintf(fout, "%d\n", request_delay); + log_messages.printf(SCHED_MSG_LOG::NORMAL, "sending delay request %d\n", request_delay); } if (strlen(message)) { fprintf(fout, diff --git a/sched/server_types.h b/sched/server_types.h index 65c7ae9b09..7233c5f1e6 100644 --- a/sched/server_types.h +++ b/sched/server_types.h @@ -55,6 +55,7 @@ struct GLOBAL_PREFS { struct SCHEDULER_REQUEST { char authenticator[256]; char platform_name[256]; + char cross_project_id[256]; int hostid; // zero if first RPC int core_client_major_version; int core_client_minor_version;