diff --git a/Makefile.in b/Makefile.in index 3bcd1710bf..69d7ff5af6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -26,17 +26,13 @@ ifndef BOINC_EMAIL BOINC_WARN_ENV = 1 BOINC_EMAIL_MSG = $(ENV_MSG_1)"BOINC_EMAIL"$(ENV_MSG_2) endif -ifndef BOINC_URL_BASE -BOINC_WARN_ENV = 1 -BOINC_URL_BASE_MSG = $(ENV_MSG_1)"BOINC_URL_BASE"$(ENV_MSG_2) -endif ifndef BOINC_KEY_DIR BOINC_WARN_ENV = 1 BOINC_KEY_DIR_MSG = $(ENV_MSG_1)"BOINC_KEY_DIR"$(ENV_MSG_2) endif -ifndef BOINC_KEY +ifndef BOINC_SHMEM_KEY BOINC_WARN_ENV = 1 -BOINC_KEY_MSG = $(ENV_MSG_1)"BOINC_KEY"$(ENV_MSG_2) +BOINC_SHMEM_KEY_MSG = $(ENV_MSG_1)"BOINC_SHMEM_KEY"$(ENV_MSG_2) endif ifndef BOINC_DB_NAME BOINC_WARN_ENV = 1 @@ -66,7 +62,7 @@ ENV_MESSAGES = "****************************************" \ $(BOINC_EMAIL_MSG) \ $(BOINC_URL_BASE_MSG) \ $(BOINC_KEY_DIR_MSG) \ - $(BOINC_KEY_MSG) \ + $(BOINC_SHMEM_KEY_MSG) \ $(BOINC_DB_NAME_MSG) \ $(BOINC_USER_MSG) \ $(BOINC_UPLOAD_URL_MSG) \ diff --git a/checkin_notes b/checkin_notes index 87750e8e40..9ec88ae71e 100755 --- a/checkin_notes +++ b/checkin_notes @@ -1667,3 +1667,35 @@ David August 24, 2002 filesys.C,h lib/ error_numbers.h + +David August 25, 2002 + - Implemented project name (as shown in GUI). + It's stored in the DB (in a single-row "project" table) + and sent in scheduler RPC + - Changed env var BOINC_KEY to BOINC_SHMEM_KEY + (avoid confusion w/ encryption keys) + + Makefile.in + client/ + cs_scheduler.C + filesys.C + scheduler_op.C,h + win/ + windows_cpp.h + wingui.cpp + db/ + db.h + db_mysql.C + schema.sql + sched/ + Makefile.in + feeder.C + main.C + server_types.C + show_shmem.C + test/ + init.inc + test_uc.php + test_uc_win.php + tools/ + add.C diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index 9bd143facc..0dab488d4b 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -182,8 +182,8 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) { p->authenticator, p->hostid, p->rpc_seqno, - platform_name, - version, + platform_name, + version, work_req ); if (p->code_sign_key) { @@ -319,6 +319,9 @@ void CLIENT_STATE::handle_scheduler_reply( f = fopen(SCHED_OP_RESULT_FILE, "r"); retval = sr.parse(f); + if (strlen(sr.project_name)) { + strcpy(project->project_name, sr.project_name); + } if (strlen(sr.message)) { show_message(sr.message, sr.message_priority); } @@ -395,23 +398,23 @@ void CLIENT_STATE::handle_scheduler_reply( if (!project->code_sign_key) { project->code_sign_key = strdup(sr.code_sign_key); } else { - if (sr.code_sign_key_signature) { - retval = verify_string2( - sr.code_sign_key, sr.code_sign_key_signature, - project->code_sign_key, signature_valid - ); - if (!retval && signature_valid) { - free(project->code_sign_key); - project->code_sign_key = strdup(sr.code_sign_key); - } else { - fprintf(stdout, - "New code signing key from %s doesn't validate\n", - project->project_name - ); - } - } else { - fprintf(stdout, "Missing code sign key signature\n"); - } + if (sr.code_sign_key_signature) { + retval = verify_string2( + sr.code_sign_key, sr.code_sign_key_signature, + project->code_sign_key, signature_valid + ); + if (!retval && signature_valid) { + free(project->code_sign_key); + project->code_sign_key = strdup(sr.code_sign_key); + } else { + fprintf(stdout, + "New code signing key from %s doesn't validate\n", + project->project_name + ); + } + } else { + fprintf(stdout, "Missing code sign key signature\n"); + } } } diff --git a/client/filesys.C b/client/filesys.C index f40d075ac6..bfb4fb62b7 100644 --- a/client/filesys.C +++ b/client/filesys.C @@ -265,7 +265,7 @@ int boinc_rename(char* old, char* newf) { #ifdef _WIN32 void full_path(char* relname, char* path) { - _getcwd(path, 256); + _getcwd(path, 256); strcat(path, PATH_SEPARATOR); strcat(path, relname); } diff --git a/client/scheduler_op.C b/client/scheduler_op.C index fdba6af063..7010f7d24e 100644 --- a/client/scheduler_op.C +++ b/client/scheduler_op.C @@ -214,7 +214,7 @@ bool SCHEDULER_OP::poll() { // here we're fetching the master file for a project // if (http_op.http_op_state == HTTP_STATE_DONE) { - action = true; + action = true; project->master_url_fetch_pending = false; http_ops->remove(&http_op); if (http_op.http_op_retval == 0) { @@ -265,7 +265,7 @@ bool SCHEDULER_OP::poll() { // scheduler_op_done = false; if (http_op.http_op_state == HTTP_STATE_DONE) { - action = true; + action = true; http_ops->remove(&http_op); if (http_op.http_op_retval) { if (log_flags.sched_op_debug) { @@ -374,6 +374,8 @@ int SCHEDULER_REPLY::parse(FILE* in) { // Do nothing } else if (match_tag(buf, "")) { return 0; + } else if (parse_str(buf, "", project_name)) { + continue; } else if (parse_int(buf, "", hostid)) { continue; } else if (parse_int(buf, "", request_delay)) { @@ -385,11 +387,11 @@ int SCHEDULER_REPLY::parse(FILE* in) { if (retval) return ERR_XML_PARSE; } else if (match_tag(buf, "")) { retval = dup_element_contents(in, "", &code_sign_key); - //fprintf(stderr, "code_sign_key: %s\n", code_sign_key); + //fprintf(stderr, "code_sign_key: %s\n", code_sign_key); if (retval) { - fprintf(stderr, "error: SCHEDULER_REPLY.parse: xml parsing error\n"); + fprintf(stderr, "error: SCHEDULER_REPLY.parse: xml parsing error\n"); return ERR_XML_PARSE; - } + } } else if (match_tag(buf, "")) { retval = dup_element_contents(in, "", &code_sign_key_signature); if (retval) return ERR_XML_PARSE; diff --git a/client/scheduler_op.h b/client/scheduler_op.h index 7ddde679c2..8010928f4c 100644 --- a/client/scheduler_op.h +++ b/client/scheduler_op.h @@ -75,6 +75,7 @@ struct SCHEDULER_REPLY { int request_delay; char message[1024]; char message_priority[256]; + char project_name[256]; int prefs_mod_time; char* prefs_xml; vector apps; diff --git a/client/win/windows_cpp.h b/client/win/windows_cpp.h index 1c9ada5292..be0d9b54c6 100644 --- a/client/win/windows_cpp.h +++ b/client/win/windows_cpp.h @@ -22,8 +22,8 @@ #ifndef _WINDOWS_CPP #define _WINDOWS_CPP -#define HOSTTYPE "Windows" -#define HOST "Windows" +#define HOSTTYPE "windows_intelx86" +#define HOST "windows_intelx86" #define VERSION 1 #include diff --git a/client/win/wingui.cpp b/client/win/wingui.cpp index 20135d72f8..965756efd9 100755 --- a/client/win/wingui.cpp +++ b/client/win/wingui.cpp @@ -16,6 +16,8 @@ #define IDC_LOGIN_OK 3 #endif +// Global vars + CMainWindow* main_window; CFont m_fontMain; CMyApp myApp; @@ -27,6 +29,82 @@ TEXT_TABLE user_info; int m_cxChar; int m_cyChar; +char* result_titles[] = {"Project", "Application", "CPU time", "status"}; +int result_widths[] = {12, 20, 12, 18}; +char* file_xfer_titles[] = {"Project", "File", "Size", "direction"}; +int file_xfer_widths[] = {12, 20, 12, 12}; +char* disk_usage_titles[] = {"Project", "space used"}; +int disk_usage_widths[] = {12, 20}; +char* project_titles[] = {"Project", "total CPU", "share"}; +int project_widths[] = {12, 15, 15}; +char* user_info_titles[] = {"Name", "Team", "Total credit", "Recent credit"}; +int user_info_widths[] = {20, 20, 15, 15}; + +void show_message(char* p, char* prior) { + //MessageBox(NULL, p, prior, MB_OK); + printf("Message (%s): %s\n", prior, p); +} + +int initialize_prefs() { + CLoginDialog dlg(IDD_LOGIN); + int retval = dlg.DoModal(); + if (retval != IDOK) return -1; + write_initial_prefs((char*)(LPCTSTR) dlg.url, (char*)(LPCTSTR) dlg.auth); + return 0; +} + +void show_result(TEXT_LINE& line, RESULT& result) { + char buf[256]; + line.set_field(0, result.project->project_name); + line.set_field(1, result.app->name); + sprintf(buf, "%f", result.final_cpu_time); + line.set_field(2, buf); + switch(result.state) { + case RESULT_NEW: + line.set_field(3, "New"); break; + case RESULT_FILES_DOWNLOADED: + line.set_field(3, "Ready to run"); break; + case RESULT_COMPUTE_DONE: + line.set_field(3, "Computation done"); break; + case RESULT_READY_TO_ACK: + line.set_field(3, "Results uploaded"); break; + case RESULT_SERVER_ACK: + line.set_field(3, "Acknowledged"); break; + } +} + +void show_file_xfer(TEXT_LINE& line, FILE_XFER& fx) { + char buf[256]; + + line.set_field(0, fx.fip->project->project_name); + line.set_field(1, fx.fip->name); + sprintf(buf, "%f", fx.fip->nbytes); + line.set_field(2, buf); + line.set_field(3, fx.fip->generated_locally?"upload":"download"); +} + +void update_gui(CLIENT_STATE& cs) { + int i, n; + + n = min(results.nlines, cs.results.size()); + for (i=0; ifile_xfers.size()); + for (i=0; ifile_xfers[i]); + } + for (i=n; iproject_name); - line.set_field(1, result.app->name); - sprintf(buf, "%f", result.final_cpu_time); - line.set_field(2, buf); -#if 0 - sprintf(buf, "%f", result.fraction_done); - line.set_field(3, buf); -#endif -} - -void show_file_xfer(TEXT_LINE& line, FILE_XFER& fx) { - char buf[256]; - - line.set_field(0, fx.fip->project->project_name); - line.set_field(1, fx.fip->name); - sprintf(buf, "%f", fx.fip->nbytes); - line.set_field(2, buf); -#if 0 - sprintf(buf, "%f", fx.fip->fraction_done*100); - line.set_field(3, buf); -#endif -} - -void update_gui(CLIENT_STATE& cs) { - int i, n; - - n = min(results.nlines, cs.results.size()); - for (i=0; ifile_xfers.size()); - for (i=0; ifile_xfers[i]); - } - for (i=n; iid, + prp->name + ); + break; case TYPE_PLATFORM: pp = (PLATFORM*)vp; sprintf(q, @@ -209,6 +220,7 @@ void struct_to_str(void* vp, char* q, int type) { } void row_to_struct(MYSQL_ROW& r, void* vp, int type) { + PROJECT* prp; PLATFORM* pp; APP* app; APP_VERSION* avp; @@ -221,6 +233,12 @@ void row_to_struct(MYSQL_ROW& r, void* vp, int type) { int i=0; assert(vp!=NULL); switch(type) { + case TYPE_PROJECT: + prp = (PROJECT*)vp; + memset(prp, 0, sizeof(PROJECT)); + prp->id = atoi(r[i++]); + strcpy(prp->name, r[i++]); + break; case TYPE_PLATFORM: pp = (PLATFORM*)vp; memset(pp, 0, sizeof(PLATFORM)); @@ -360,6 +378,17 @@ void row_to_struct(MYSQL_ROW& r, void* vp, int type) { } +////////// PROJECT ///////// + +int db_project_new(PROJECT& p) { + return db_new(&p, TYPE_PROJECT); +} + +int db_project_enum(PROJECT& p) { + static ENUM e; + return db_enum(e, &p, TYPE_PROJECT); +} + ////////// PLATFORM ///////// int db_platform_new(PLATFORM& p) { diff --git a/db/schema.sql b/db/schema.sql index 3b75063e78..bef5713059 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -1,5 +1,11 @@ use BOINC_DB_NAME +create table project ( + id integer not null auto_increment, + name varchar(254) not null, + primary key (id) +); + create table platform ( id integer not null auto_increment, create_time integer not null, diff --git a/sched/Makefile.in b/sched/Makefile.in index 8eafafbd57..3a07c92539 100644 --- a/sched/Makefile.in +++ b/sched/Makefile.in @@ -13,7 +13,7 @@ CFLAGS = -g -Wall @DEFS@ \ -I@top_srcdir@/tools \ -DBOINC_DB_NAME=\"$(BOINC_DB_NAME)\" \ -DBOINC_DB_PASSWD=\"$(BOINC_DB_PASSWD)\" \ - -DBOINC_KEY=$(BOINC_KEY) \ + -DBOINC_SHMEM_KEY=$(BOINC_SHMEM_KEY) \ -DBOINC_KEY_DIR=\"$(BOINC_KEY_DIR)\" \ -DBOINC_UPLOAD_DIR=\"$(BOINC_UPLOAD_DIR)\" \ -DBOINC_USER=\"$(BOINC_USER)\" \ diff --git a/sched/feeder.C b/sched/feeder.C index 776428bd03..4291554f83 100644 --- a/sched/feeder.C +++ b/sched/feeder.C @@ -65,7 +65,7 @@ int check_trigger(SCHED_SHMEM* ssp) { fclose(f); if (!strcmp(buf, "\n")) { detach_shmem((void*)ssp); - destroy_shmem(BOINC_KEY); + destroy_shmem(BOINC_SHMEM_KEY); unlink(TRIGGER_FILENAME); exit(0); } else if (!strcmp(buf, "\n")) { @@ -179,12 +179,12 @@ int main(int argc, char** argv) { } } - retval = destroy_shmem(BOINC_KEY); + retval = destroy_shmem(BOINC_SHMEM_KEY); if (retval) { fprintf(stderr, "feeder: can't destroy shmem\n"); exit(1); } - retval = create_shmem(BOINC_KEY, sizeof(SCHED_SHMEM), &p); + retval = create_shmem(BOINC_SHMEM_KEY, sizeof(SCHED_SHMEM), &p); if (retval) { fprintf(stderr, "feeder: can't create shmem\n"); exit(1); diff --git a/sched/main.C b/sched/main.C index f9e7155bc9..8b5292c06a 100644 --- a/sched/main.C +++ b/sched/main.C @@ -27,12 +27,16 @@ #include "shmem.h" #include "server_types.h" #include "handle_request.h" +#include "main.h" #define REQ_FILE_PREFIX "/tmp/boinc_req_" #define REPLY_FILE_PREFIX "/tmp/boinc_reply_" +//#define REQ_FILE_PREFIX "/disks/milkyway/a/users/anderson/boinc_cvs/boinc/sched/boinc_req_" +//#define REPLY_FILE_PREFIX "/disks/milkyway/a/users/anderson/boinc_cvs/boinc/sched/boinc_reply_" + +PROJECT gproject; int return_error(char* p) { - assert(p!=NULL); fprintf(stderr, "BOINC server: %s\n", p); printf("%s\n", p); return 1; @@ -52,42 +56,74 @@ int main() { void* p; unsigned int counter=0; char* code_sign_key; + bool found; sprintf(path, "%s/code_sign_public", BOINC_KEY_DIR); retval = read_file_malloc(path, code_sign_key); if (retval) { fprintf(stderr, - "BOINC scheduler - compiled by BOINC_USER: can't read code sign key file (%s)\n", path + "BOINC scheduler (%s): can't read code sign key file (%s)\n", + BOINC_USER, path ); exit(1); } - retval = attach_shmem(BOINC_KEY, &p); + retval = attach_shmem(BOINC_SHMEM_KEY, &p); if (retval) { - fprintf(stderr, "BOINC scheduler - Compiled by BOINC_USER: can't attach shmem\n"); + fprintf(stderr, + "BOINC scheduler (%s): can't attach shmem\n", + BOINC_USER + ); exit(1); } ssp = (SCHED_SHMEM*)p; retval = ssp->verify(); if (retval) { - fprintf(stderr, "BOINC scheduler - Compiled by BOINC_USER: shmem has wrong struct sizes - recompile\n"); + fprintf(stderr, + "BOINC scheduler (%s): shmem has wrong struct sizes - recompile\n", + BOINC_USER + ); exit(1); } for (i=0; i<10; i++) { if (ssp->ready) break; - fprintf(stderr, "BOINC scheduler - Compiled by BOINC_USER: waiting for ready flag\n"); + fprintf(stderr, + "BOINC scheduler (%s): waiting for ready flag\n", + BOINC_USER + ); sleep(1); } if (!ssp->ready) { - fprintf(stderr, "BOINC scheduler - Compiled by BOINC_USER: feeder doesn't seem to be running\n"); + fprintf(stderr, + "BOINC scheduler (%s): feeder doesn't seem to be running\n", + BOINC_USER + ); exit(1); } //fprintf(stderr, "got ready flag\n"); retval = db_open(BOINC_DB_NAME, BOINC_DB_PASSWD); if (retval) { - exit(return_error("BOINC scheduler - Compiled by BOINC_USER: can't open database")); + fprintf(stderr, + "BOINC scheduler (%s): can't open database\n", + BOINC_USER + ); + return_error("can't open database"); + exit(1); } + + found = false; + while (!db_project_enum(gproject)) { + found = true; + } + if (!found) { + fprintf(stderr, + "BOINC scheduler (%s): can't find project\n", + BOINC_USER + ); + exit(1); + } + pid = getpid(); #ifdef _USING_FCGI_ while(FCGI_Accept() >= 0) { diff --git a/sched/server_types.C b/sched/server_types.C index 6b82fbba0d..6f03e6275b 100644 --- a/sched/server_types.C +++ b/sched/server_types.C @@ -21,6 +21,7 @@ #include #include "parse.h" +#include "main.h" #include "server_types.h" SCHEDULER_REQUEST::SCHEDULER_REQUEST() { @@ -109,8 +110,11 @@ int SCHEDULER_REPLY::write(FILE* fout) { assert(fout!=NULL); fprintf(fout, "\n" + "%s\n", + gproject.name ); + if (request_delay) { fprintf(fout, "%d\n", request_delay); } diff --git a/sched/show_shmem.C b/sched/show_shmem.C index 4c80045979..b33aa8b54a 100644 --- a/sched/show_shmem.C +++ b/sched/show_shmem.C @@ -8,7 +8,7 @@ int main() { int retval; void* p; - retval = attach_shmem(BOINC_KEY, &p); + retval = attach_shmem(BOINC_SHMEM_KEY, &p); if (retval) { printf("can't attach shmem\n"); exit(1); diff --git a/test/init.inc b/test/init.inc index bffdc41183..44f6717ba4 100644 --- a/test/init.inc +++ b/test/init.inc @@ -131,6 +131,10 @@ function add_prefs($file) { PassThru("../tools/add prefs -email_addr $BOINC_EMAIL -prefs_file $file"); } +function add_project($name) { + PassThru("../tools/add project -project_name '$name'"); +} + function add_platform($platform) { global $BOINC_PLATFORM; diff --git a/test/test_uc.php b/test/test_uc.php index 6b8f856ce7..fe6fb34218 100644 --- a/test/test_uc.php +++ b/test/test_uc.php @@ -12,6 +12,7 @@ create_keys(); init_client_dirs("prefs1.xml"); copy_to_download_dir("input"); + add_project("Test Project"); add_platform(null); add_user("prefs.xml"); add_app("upper_case", null, null); diff --git a/test/test_uc_win.php b/test/test_uc_win.php index bfed6a10a8..88d3f4bdab 100644 --- a/test/test_uc_win.php +++ b/test/test_uc_win.php @@ -11,6 +11,7 @@ create_keys(); init_client_dirs("prefs1.xml"); copy_to_download_dir("input"); + add_project("Test Project"); add_platform("windows_intelx86"); add_user("prefs.xml"); add_app("upper_case", "windows_intelx86", "upper_case.exe"); diff --git a/tools/add.C b/tools/add.C index 610f3e4979..d050639104 100644 --- a/tools/add.C +++ b/tools/add.C @@ -20,6 +20,8 @@ // add.C - add items to the DB // // usages: +// add project -project_name x +// add project // add app -app_name x // add application // create DB record @@ -49,17 +51,30 @@ APP app; PLATFORM platform; APP_VERSION app_version; USER user; +PROJECT project; + int version, retval, nexec_files; double nbytes; bool signed_exec_files; char buf[256], md5_cksum[64]; -char *app_name=0, *platform_name=0; +char *app_name=0, *platform_name=0, *project_name=0; char* exec_dir=0, *exec_files[10], *signature_files[10]; char *email_addr=0, *user_name=0, *web_password=0, *authenticator=0; char *prefs_file=0, *download_dir, *download_url; char* code_sign_keyfile; char *message=0, *message_priority=0; +void add_project() { + int retval; + + memset(&project, 0, sizeof(project)); + strcpy(project.name, project_name); + retval = db_project_new(project); + if (retval) { + db_print_error("db_project_new"); + } +} + void add_app() { int retval; @@ -258,7 +273,10 @@ int main(int argc, char** argv) { printf("can't open DB %s\n", getenv("BOINC_DB_NAME")); } for (i=2; i