// write XML list of supported platforms // void CLIENT_STATE::write_platforms(PROJECT* p, MIOFILE& mf) { mf.printf( " <platform_name>%s</platform_name>\n", p->anonymous_platform ? "anonymous" : get_primary_platform() ); for (unsigned int i=1; i<platforms.size(); i++) { PLATFORM& platform = platforms[i]; mf.printf( " <alt_platform>\n" " <name>%s</name>\n" " </alt_platform>\n", platform.name.c_str() ); } }
int CLIENT_STATE::write_state_gui(MIOFILE& f) { unsigned int i, j; int retval; f.printf("<client_state>\n"); retval = host_info.write(f, true, true); if (retval) return retval; // the following are for compatibility with old managers // if (coprocs.have_nvidia()) { f.printf("<have_cuda/>\n"); } if (coprocs.have_ati()) { f.printf("<have_ati/>\n"); } #if 1 // NOTE: the following is not in CC_STATE. // However, BoincView (which does its own parsing) expects it // to be in the get_state() reply, so leave it in for now // retval = net_stats.write(f); if (retval) return retval; #endif retval = time_stats.write(f, true); if (retval) return retval; for (j=0; j<projects.size(); j++) { PROJECT* p = projects[j]; retval = p->write_state(f, true); if (retval) return retval; for (i=0; i<apps.size(); i++) { if (apps[i]->project == p) { retval = apps[i]->write(f); if (retval) return retval; } } for (i=0; i<app_versions.size(); i++) { if (app_versions[i]->project == p) app_versions[i]->write(f); } for (i=0; i<workunits.size(); i++) { if (workunits[i]->project == p) workunits[i]->write(f); } for (i=0; i<results.size(); i++) { if (results[i]->project == p) results[i]->write_gui(f); } } f.printf( "<platform_name>%s</platform_name>\n" "<core_client_major_version>%d</core_client_major_version>\n" "<core_client_minor_version>%d</core_client_minor_version>\n" "<core_client_release>%d</core_client_release>\n" "<executing_as_daemon>%d</executing_as_daemon>\n", get_primary_platform(), core_client_version.major, core_client_version.minor, core_client_version.release, executing_as_daemon?1:0 ); for (i=0; i<platforms.size(); i++) { f.printf( "<platform>%s</platform>\n", platforms[i].name.c_str() ); } global_prefs.write(f); // the following used by BoincView - don't remove // if (strlen(main_host_venue)) { f.printf("<host_venue>%s</host_venue>\n", main_host_venue); } f.printf("</client_state>\n"); return 0; }
int CLIENT_STATE::write_state(MIOFILE& f) { unsigned int i, j; int retval; #ifdef SIM fprintf(stderr, "simulator shouldn't write state file\n"); exit(1); #endif f.printf("<client_state>\n"); retval = host_info.write(f, true, true); if (retval) return retval; retval = time_stats.write(f, false); if (retval) return retval; retval = net_stats.write(f); if (retval) return retval; for (j=0; j<projects.size(); j++) { PROJECT* p = projects[j]; retval = p->write_state(f); if (retval) return retval; for (i=0; i<apps.size(); i++) { if (apps[i]->project == p) { retval = apps[i]->write(f); if (retval) return retval; } } for (i=0; i<file_infos.size(); i++) { if (file_infos[i]->project != p) continue; FILE_INFO* fip = file_infos[i]; // don't write file infos for anonymous platform app files // if (fip->anonymous_platform_file) continue; retval = fip->write(f, false); if (retval) return retval; } for (i=0; i<app_versions.size(); i++) { if (app_versions[i]->project == p) { app_versions[i]->write(f); } } for (i=0; i<workunits.size(); i++) { if (workunits[i]->project == p) workunits[i]->write(f); } for (i=0; i<results.size(); i++) { if (results[i]->project == p) results[i]->write(f, false); } p->write_project_files(f); #ifdef ENABLE_AUTO_UPDATE if (auto_update.present && auto_update.project==p) { auto_update.write(f); } #endif } active_tasks.write(f); f.printf( "<platform_name>%s</platform_name>\n" "<core_client_major_version>%d</core_client_major_version>\n" "<core_client_minor_version>%d</core_client_minor_version>\n" "<core_client_release>%d</core_client_release>\n" "<user_run_request>%d</user_run_request>\n" "<user_run_prev_request>%d</user_run_prev_request>\n" "<user_gpu_request>%d</user_gpu_request>\n" "<user_gpu_prev_request>%d</user_gpu_prev_request>\n" "<user_network_request>%d</user_network_request>\n" "<new_version_check_time>%f</new_version_check_time>\n" "<all_projects_list_check_time>%f</all_projects_list_check_time>\n", get_primary_platform(), core_client_version.major, core_client_version.minor, core_client_version.release, cpu_run_mode.get_perm(), cpu_run_mode.get_prev(), gpu_run_mode.get_perm(), gpu_run_mode.get_prev(), network_run_mode.get_perm(), new_version_check_time, all_projects_list_check_time ); if (strlen(language)) { f.printf("<language>%s</language>\n", language); } if (newer_version.size()) { f.printf("<newer_version>%s</newer_version>\n", newer_version.c_str()); } for (i=1; i<platforms.size(); i++) { f.printf("<alt_platform>%s</alt_platform>\n", platforms[i].name.c_str()); } if (gui_proxy_info.present) { gui_proxy_info.write(f); } if (strlen(main_host_venue)) { f.printf("<host_venue>%s</host_venue>\n", main_host_venue); } f.printf("</client_state>\n"); return 0; }
// parse a project's app_info.xml (anonymous platform) file // int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) { char buf[256], path[MAXPATHLEN]; MIOFILE mf; mf.init_file(in); XML_PARSER xp(&mf); while (!xp.get_tag()) { if (xp.match_tag("app_info")) continue; if (xp.match_tag("/app_info")) { notices.remove_notices(p, REMOVE_APP_INFO_MSG); return 0; } if (xp.match_tag("file_info") || xp.match_tag("file")) { FILE_INFO* fip = new FILE_INFO; if (fip->parse(xp)) { delete fip; continue; } if (!fip->download_urls.empty() || !fip->upload_urls.empty()) { msg_printf(p, MSG_INFO, "Can't specify URLs in app_info.xml" ); delete fip; continue; } if (link_file_info(p, fip)) { delete fip; continue; } // check that the file is actually there // get_pathname(fip, path, sizeof(path)); if (!boinc_file_exists(path)) { safe_strcpy(buf, _("File referenced in app_info.xml does not exist: ") ); strcat(buf, fip->name); msg_printf(p, MSG_USER_ALERT, "%s", buf); delete fip; continue; } fip->status = FILE_PRESENT; fip->anonymous_platform_file = true; file_infos.push_back(fip); continue; } if (xp.match_tag("app")) { APP* app = new APP; if (app->parse(xp)) { delete app; continue; } if (lookup_app(p, app->name)) { delete app; continue; } link_app(p, app); apps.push_back(app); continue; } if (xp.match_tag("app_version")) { APP_VERSION* avp = new APP_VERSION; if (avp->parse(xp)) { delete avp; continue; } if (cc_config.dont_use_vbox && strstr(avp->plan_class, "vbox")) { msg_printf(p, MSG_INFO, "skipping vbox app in app_info.xml; vbox disabled in cc_config.xml" ); delete avp; continue; } if (strlen(avp->platform) == 0) { safe_strcpy(avp->platform, get_primary_platform()); } if (link_app_version(p, avp)) { delete avp; continue; } app_versions.push_back(avp); continue; } if (log_flags.unparsed_xml) { msg_printf(p, MSG_INFO, "Unparsed line in app_info.xml: %s", xp.parsed_tag ); } } return ERR_XML_PARSE; }
int CLIENT_STATE::parse_state_file_aux(const char* fname) { PROJECT *project=NULL; int retval=0; string stemp; FILE* f = fopen(fname, "r"); if (!f) return ERR_FOPEN; MIOFILE mf; XML_PARSER xp(&mf); mf.init_file(f); while (!xp.get_tag()) { if (xp.match_tag("/client_state")) { break; } if (xp.match_tag("client_state")) { continue; } if (xp.match_tag("project")) { PROJECT temp_project; retval = temp_project.parse_state(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse project in state file"); } else { #ifdef SIM project = new PROJECT; *project = temp_project; projects.push_back(project); #else project = lookup_project(temp_project.master_url); if (project) { project->copy_state_fields(temp_project); } else { msg_printf(&temp_project, MSG_INTERNAL_ERROR, "Project %s is in state file but no account file found", temp_project.get_project_name() ); } #endif } continue; } if (xp.match_tag("app")) { APP* app = new APP; retval = app->parse(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Application %s outside project in state file", app->name ); delete app; continue; } if (project->anonymous_platform) { delete app; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse application in state file" ); delete app; continue; } retval = link_app(project, app); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't handle application %s in state file", app->name ); delete app; continue; } apps.push_back(app); continue; } if (xp.match_tag("file_info") || xp.match_tag("file")) { FILE_INFO* fip = new FILE_INFO; retval = fip->parse(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "File info outside project in state file" ); delete fip; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't handle file info in state file" ); delete fip; continue; } retval = link_file_info(project, fip); if (project->anonymous_platform && retval == ERR_NOT_UNIQUE) { delete fip; continue; } if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't handle file info %s in state file", fip->name ); delete fip; continue; } file_infos.push_back(fip); #ifndef SIM // If the file had a failure before, // don't start another file transfer // int failnum; if (fip->had_failure(failnum)) { if (fip->pers_file_xfer) { delete fip->pers_file_xfer; fip->pers_file_xfer = NULL; } } if (fip->pers_file_xfer) { retval = fip->pers_file_xfer->init(fip, fip->pers_file_xfer->is_upload); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't initialize file transfer for %s", fip->name ); } retval = pers_file_xfers->insert(fip->pers_file_xfer); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't start persistent file transfer for %s", fip->name ); } } #endif continue; } if (xp.match_tag("app_version")) { APP_VERSION* avp = new APP_VERSION; retval = avp->parse(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Application version outside project in state file" ); delete avp; continue; } if (project->anonymous_platform) { delete avp; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse application version in state file" ); delete avp; continue; } if (strlen(avp->platform) == 0) { safe_strcpy(avp->platform, get_primary_platform()); } else { if (!is_supported_platform(avp->platform)) { // if it's a platform we haven't heard of, // must be that the user tried out a 64 bit client // and then reverted to a 32-bit client. // Let's not throw away the app version and its WUs // #ifndef SIM msg_printf(project, MSG_INTERNAL_ERROR, "App version has unsupported platform %s; changing to %s", avp->platform, get_primary_platform() ); #endif safe_strcpy(avp->platform, get_primary_platform()); } } if (avp->missing_coproc) { msg_printf(project, MSG_INFO, "Application uses missing %s GPU", avp->missing_coproc_name ); } retval = link_app_version(project, avp); if (retval) { delete avp; continue; } app_versions.push_back(avp); continue; } if (xp.match_tag("workunit")) { WORKUNIT* wup = new WORKUNIT; retval = wup->parse(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Workunit outside project in state file" ); delete wup; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse workunit in state file" ); delete wup; continue; } retval = link_workunit(project, wup); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't handle workunit in state file" ); delete wup; continue; } workunits.push_back(wup); continue; } if (xp.match_tag("result")) { RESULT* rp = new RESULT; retval = rp->parse_state(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Task %s outside project in state file", rp->name ); delete rp; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse task in state file" ); delete rp; continue; } retval = link_result(project, rp); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't link task %s in state file", rp->name ); delete rp; continue; } // handle transition from old clients which didn't store result.platform; // skip for anon platform if (!project->anonymous_platform) { if (!strlen(rp->platform) || !is_supported_platform(rp->platform)) { safe_strcpy(rp->platform, get_primary_platform()); rp->version_num = latest_version(rp->wup->app, rp->platform); } } rp->avp = lookup_app_version( rp->wup->app, rp->platform, rp->version_num, rp->plan_class ); if (!rp->avp) { msg_printf(project, MSG_INTERNAL_ERROR, "No application found for task: %s %d %s; discarding", rp->platform, rp->version_num, rp->plan_class ); delete rp; continue; } if (rp->avp->missing_coproc) { msg_printf(project, MSG_INFO, "Missing coprocessor for task %s", rp->name ); rp->coproc_missing = true; } rp->wup->version_num = rp->version_num; results.push_back(rp); continue; } if (xp.match_tag("project_files")) { if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Project files outside project in state file" ); xp.skip_unexpected(); continue; } parse_project_files(xp, project->project_files); project->link_project_files(); continue; } if (xp.match_tag("host_info")) { #ifdef SIM retval = host_info.parse(xp, false); coprocs = host_info.coprocs; coprocs.bound_counts(); #else retval = host_info.parse(xp, true); #endif if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse host info in state file" ); } continue; } if (xp.match_tag("time_stats")) { retval = time_stats.parse(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse time stats in state file" ); } continue; } if (xp.match_tag("net_stats")) { retval = net_stats.parse(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse network stats in state file" ); } continue; } if (xp.match_tag("active_task_set")) { retval = active_tasks.parse(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse active tasks in state file" ); } continue; } if (xp.parse_string("platform_name", statefile_platform_name)) { continue; } if (xp.parse_string("alt_platform", stemp)) { continue; } if (xp.parse_int("user_run_request", retval)) { cpu_run_mode.set(retval, 0); continue; } if (xp.parse_int("user_run_prev_request", retval)) { cpu_run_mode.set_prev(retval); continue; } if (xp.parse_int("user_gpu_request", retval)) { gpu_run_mode.set(retval, 0); continue; } if (xp.parse_int("user_gpu_prev_request", retval)) { gpu_run_mode.set_prev(retval); continue; } if (xp.parse_int("user_network_request", retval)) { network_run_mode.set(retval, 0); continue; } if (xp.parse_int("core_client_major_version", old_major_version)) { continue; } if (xp.parse_int("core_client_minor_version", old_minor_version)) { continue; } if (xp.parse_int("core_client_release", old_release)) { continue; } if (xp.parse_str("language", language, sizeof(language))) { continue; } if (xp.match_tag("proxy_info")) { retval = gui_proxy_info.parse(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse proxy info in state file" ); } continue; } if (xp.parse_str("host_venue", main_host_venue, sizeof(main_host_venue))) { continue; } if (xp.parse_double("new_version_check_time", new_version_check_time)) { continue; } if (xp.parse_double("all_projects_list_check_time", all_projects_list_check_time)) { continue; } if (xp.parse_string("newer_version", newer_version)) { continue; } #ifdef ENABLE_AUTO_UPDATE if (xp.match_tag("auto_update")) { if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "auto update outside project in state file" ); xp.skip_unexpected(); continue; } if (!auto_update.parse(xp) && !auto_update.validate_and_link(project)) { auto_update.present = true; } continue; } #endif if (log_flags.unparsed_xml) { msg_printf(0, MSG_INFO, "[unparsed_xml] state_file: unrecognized: %s", xp.parsed_tag ); } xp.skip_unexpected(); } sort_results(); fclose(f); // if total resource share is zero, set all shares to 1 // if (projects.size()) { unsigned int i; double x=0; for (i=0; i<projects.size(); i++) { x += projects[i]->resource_share; } if (!x) { msg_printf(NULL, MSG_INFO, "All projects have zero resource share; setting to 100" ); for (i=0; i<projects.size(); i++) { projects[i]->resource_share = 100; } } } return 0; }