*** empty log message ***

svn path=/trunk/boinc/; revision=3308
This commit is contained in:
David Anderson 2004-04-30 18:26:20 +00:00
parent e3b01ec028
commit 00191f0456
8 changed files with 57 additions and 19 deletions

View File

@ -11842,3 +11842,19 @@ Rom April 28 2004
win_build/ win_build/
boinc_cli.vcproj 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 <cross_project_id> 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

View File

@ -14,8 +14,8 @@ function db_init() {
$pass = parse_config("<db_passwd>"); $pass = parse_config("<db_passwd>");
$retval = mysql_pconnect("localhost", $user, $pass); $retval = mysql_pconnect("localhost", $user, $pass);
if (!$retval) { if (!$retval) {
echo "Unable to connect to database - please try again later"; echo "Unable to connect to database - please try again later\n";
echo mysql_error(); echo "Error: ", mysql_errno(), mysql_error();
exit(); exit();
} }
$db_name = parse_config("<db_name>"); $db_name = parse_config("<db_name>");

View File

@ -67,7 +67,7 @@ function show_error($str) {
$cross_project_id = random_string(); $cross_project_id = random_string();
$munged_email_addr = munge_email_addr($new_email_addr, $authenticator); $munged_email_addr = munge_email_addr($new_email_addr, $authenticator);
$query = sprintf( $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(), time(),
$munged_email_addr, $munged_email_addr,
$new_name, $new_name,

View File

@ -490,6 +490,7 @@ bool wrong_major_version(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
sreq.hostid, sreq.authenticator, sreq.hostid, sreq.authenticator,
MAJOR_VERSION, sreq.core_client_major_version MAJOR_VERSION, sreq.core_client_major_version
); );
reply.request_delay = 3600*24;
return true; return true;
} }
return false; return false;
@ -567,6 +568,14 @@ void process_request(
// //
if (wrong_major_version(sreq, reply)) return; 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); retval = authenticate_user(sreq, reply);
if (retval) return; if (retval) return;
if (reply.user.id == 0) { if (reply.user.id == 0) {

View File

@ -33,6 +33,7 @@ using namespace std;
#include "boinc_db.h" #include "boinc_db.h"
#include "parse.h" #include "parse.h"
#include "filesys.h" #include "filesys.h"
#include "error_numbers.h"
#include "shmem.h" #include "shmem.h"
#include "util.h" #include "util.h"
@ -64,10 +65,32 @@ void send_shut_message() {
"Content-type: text/plain\n\n" "Content-type: text/plain\n\n"
"<scheduler_reply>\n" "<scheduler_reply>\n"
" <message priority=\"low\">Project is temporarily shut down for maintenance</message>\n" " <message priority=\"low\">Project is temporarily shut down for maintenance</message>\n"
" <request_delay>3600</request_delay>\n"
"</scheduler_reply>\n" "</scheduler_reply>\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() { int main() {
FILE* fin, *fout; FILE* fin, *fout;
int i, retval, pid; int i, retval, pid;
@ -76,7 +99,6 @@ int main() {
void* p; void* p;
unsigned int counter=0; unsigned int counter=0;
char* code_sign_key; char* code_sign_key;
bool found;
bool project_stopped = false; bool project_stopped = false;
get_log_path(path); 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(); pid = getpid();
#ifdef _USING_FCGI_ #ifdef _USING_FCGI_
while(FCGI_Accept() >= 0) { while(FCGI_Accept() >= 0) {

View File

@ -24,3 +24,6 @@
extern DB_PROJECT gproject; extern DB_PROJECT gproject;
extern SCHED_CONFIG config; extern SCHED_CONFIG config;
extern key_t sema_key; extern key_t sema_key;
extern void send_shut_message();
extern int open_database();

View File

@ -68,6 +68,7 @@ int SCHEDULER_REQUEST::parse(FILE* fin) {
while (fgets(buf, 256, fin)) { while (fgets(buf, 256, fin)) {
if (match_tag(buf, "</scheduler_request>")) return 0; if (match_tag(buf, "</scheduler_request>")) return 0;
else if (parse_str(buf, "<authenticator>", authenticator, sizeof(authenticator))) continue; else if (parse_str(buf, "<authenticator>", authenticator, sizeof(authenticator))) continue;
else if (parse_str(buf, "<cross_project_id>", cross_project_id, sizeof(cross_project_id))) continue;
else if (parse_int(buf, "<hostid>", hostid)) continue; else if (parse_int(buf, "<hostid>", hostid)) continue;
else if (parse_int(buf, "<rpc_seqno>", rpc_seqno)) continue; else if (parse_int(buf, "<rpc_seqno>", rpc_seqno)) continue;
else if (parse_str(buf, "<platform_name>", platform_name, sizeof(platform_name))) continue; else if (parse_str(buf, "<platform_name>", platform_name, sizeof(platform_name))) continue;
@ -184,6 +185,7 @@ int SCHEDULER_REPLY::write(FILE* fout) {
if (request_delay) { if (request_delay) {
fprintf(fout, "<request_delay>%d</request_delay>\n", request_delay); fprintf(fout, "<request_delay>%d</request_delay>\n", request_delay);
log_messages.printf(SCHED_MSG_LOG::NORMAL, "sending delay request %d\n", request_delay);
} }
if (strlen(message)) { if (strlen(message)) {
fprintf(fout, fprintf(fout,

View File

@ -55,6 +55,7 @@ struct GLOBAL_PREFS {
struct SCHEDULER_REQUEST { struct SCHEDULER_REQUEST {
char authenticator[256]; char authenticator[256];
char platform_name[256]; char platform_name[256];
char cross_project_id[256];
int hostid; // zero if first RPC int hostid; // zero if first RPC
int core_client_major_version; int core_client_major_version;
int core_client_minor_version; int core_client_minor_version;