diff --git a/api/boinc_api.h b/api/boinc_api.h index 6f23021a65..e58d67f23d 100644 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -30,6 +30,12 @@ extern "C" { #endif typedef struct BOINC_OPTIONS { // the following are booleans, implemented as ints for portability + int backwards_compatible_graphics; + // V6 apps should set this so that "Show Graphics" will work + // with pre-V6 clients + int normal_thread_priority; + // run app at normal thread priority on Win. + // (default is idle priority) int main_program; // this is the main program, so // - lock a lock file in the slot directory @@ -48,14 +54,6 @@ typedef struct BOINC_OPTIONS { // if heartbeat fail, or get process control msg, take // direction action (exit, suspend, resume). // Otherwise just set flag in BOINC status - int worker_thread_stack_size; - // if nonzero, the worker thread stack size limit - int backwards_compatible_graphics; - // V6 apps should set this so that "Show Graphics" will work - // with pre-V6 clients - int normal_thread_priority; - // run app at normal thread priority on Win. - // (default is idle priority) } BOINC_OPTIONS; typedef struct BOINC_STATUS { @@ -146,7 +144,6 @@ inline void boinc_options_defaults(BOINC_OPTIONS& b) { b.handle_process_control = 1; b.send_status_msgs = 1; b.direct_process_action = 1; - b.worker_thread_stack_size = 0; b.backwards_compatible_graphics = 1; b.normal_thread_priority = 0; } diff --git a/api/graphics_impl.cpp b/api/graphics_impl.cpp index 2c28d8c275..ce35890200 100644 --- a/api/graphics_impl.cpp +++ b/api/graphics_impl.cpp @@ -21,6 +21,8 @@ // and thus can be put in a shared library, // separate from the application. +// DEPRECATED - use separate graphics app + #ifndef _WIN32 #include "config.h" #endif diff --git a/checkin_notes b/checkin_notes index 1ba5f1c800..391aa58c8d 100644 --- a/checkin_notes +++ b/checkin_notes @@ -10271,3 +10271,19 @@ Charlie 17 Dec 2008 boinc.xcodeproj/ project.pbxproj +David 19 Dec 2008 + - API: remove BOINC_OPTIONS::worker_thread_stack_size + - web: check whether to show profile in separate function + from displaying profile; eliminate double headers + - scheduler: finish purge of redundant arguments + + api/ + boinc_api.h + grephics_impl.cpp + html/ + inc/ + profile.inc + user/ + view_profile.php + sched/ + (many files) diff --git a/doc/cuda.php b/doc/cuda.php index e7d16d8b5f..0a0288b118 100644 --- a/doc/cuda.php +++ b/doc/cuda.php @@ -20,9 +20,11 @@ With NVIDIA's assistance, some BOINC-based projects have applications that run on NVIDIA GPUs using CUDA. These applications run from 2X to 10X faster than the CPU-only version. We urge BOINC participants to use them if possible. -

Just follow these instructions:

+(Note: CUDA apps are supported only on Windows and Linux; +Mac OS X support is coming soon.) +

1) Check whether your computer has a CUDA-capable GPU

CUDA programs work on most newer NVIDIA GPUs. diff --git a/html/inc/profile.inc b/html/inc/profile.inc index 59e0209870..9f3d262d3c 100644 --- a/html/inc/profile.inc +++ b/html/inc/profile.inc @@ -183,6 +183,19 @@ function get_profile_summary($profile) { return $summary; } +function check_whether_to_show_profile($user, $logged_in_user) { + $min_credit = parse_config(get_config(), ""); + if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) { + error_page( + "To prevent spam, profiles of users with an average credit of less than $min_credit are displayed only to logged-in users. We apologize for this inconvenience." + ); + } + if (is_banished($user)) { + error_page("User is banished"); + } + +} + // Displays a user's profile (if they have one); // $screen_mode is set if we're in the administrative profile-screening page, // in which case we show everything @@ -192,23 +205,12 @@ function show_profile($user, $logged_in_user, $screen_mode = false) { BoincForumPrefs::lookup($user); $profile = BoincProfile::lookup("userid = $user->id"); if (!$profile) { - error_page("No user profile exists for that user ID."); + row1("No profile exists for that user ID."); $user->update("has_profile = 0"); + return; } - $is_logged_in = isset($logged_in_user); - - $can_edit = isset($logged_in_user) && $logged_in_user && $user->id == $logged_in_user->id; - - $min_credit = parse_config(get_config(), ""); - if ((!$is_logged_in) && $min_credit && $user->expavg_credit < $min_credit ) { - error_page( - "To prevent spam, profiles of users with an average credit of less than $min_credit will only be displayed to users who are logged in to their accounts. We appologize for this inconvenience." - ); - } - if (is_banished($user)) { - error_page("User is banished"); - } + $can_edit = $logged_in_user && $user->id == $logged_in_user->id; if ($can_edit) { row1("Edit your profile"); diff --git a/html/user/view_profile.php b/html/user/view_profile.php index c32e7667ea..2466a2944e 100644 --- a/html/user/view_profile.php +++ b/html/user/view_profile.php @@ -28,12 +28,16 @@ if (!$user->has_profile) { } $logged_in_user = get_logged_in_user(false); + +check_whether_to_show_profile($user, $logged_in_user); + $caching = false; if (!$logged_in_user) { $caching = true; $cache_args = "userid=$userid"; start_cache(USER_PROFILE_TTL, $cache_args); } + page_head("Profile: $user->name"); start_table(); echo ""; diff --git a/sched/handle_request.cpp b/sched/handle_request.cpp index 9d5e014ca9..3781cf7233 100644 --- a/sched/handle_request.cpp +++ b/sched/handle_request.cpp @@ -93,11 +93,11 @@ static void get_weak_auth(USER& user, char* buf) { sprintf(buf, "%d_%s", user.id, out); } -static void send_error_message(SCHEDULER_REPLY& reply, const char* msg, int delay) { +static void send_error_message(const char* msg, int delay) { USER_MESSAGE um(msg, "low"); - reply.insert_message(um); - reply.set_delay(delay); - reply.nucleus_only = true; + g_reply->insert_message(um); + g_reply->set_delay(delay); + g_reply->nucleus_only = true; } // Try to lock a file with name based on host ID, @@ -109,14 +109,14 @@ static void send_error_message(SCHEDULER_REPLY& reply, const char* msg, int dela // PID (>0) if another process has lock // -1 if error (e.g. can't create file) // -int lock_sched(SCHEDULER_REPLY& reply) { +int lock_sched() { char filename[256]; char pid_string[16]; int fd, pid, count; - reply.lockfile_fd=-1; + g_reply->lockfile_fd=-1; - sprintf(filename, "%s/CGI_%07d", config.sched_lockfile_dir, reply.host.id); + sprintf(filename, "%s/CGI_%07d", config.sched_lockfile_dir, g_reply->host.id); fd = open(filename, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (fd < 0) return -1; @@ -137,19 +137,19 @@ int lock_sched(SCHEDULER_REPLY& reply) { write(fd, pid_string, count); fsync(fd); - reply.lockfile_fd = fd; + g_reply->lockfile_fd = fd; return 0; } // unlock and delete per-host lockfile // -void unlock_sched(SCHEDULER_REPLY& reply) { +void unlock_sched() { char filename[256]; - if (reply.lockfile_fd < 0) return; - sprintf(filename, "%s/CGI_%07d", config.sched_lockfile_dir, reply.host.id); + if (g_reply->lockfile_fd < 0) return; + sprintf(filename, "%s/CGI_%07d", config.sched_lockfile_dir, g_reply->host.id); unlink(filename); - close(reply.lockfile_fd); + close(g_reply->lockfile_fd); } @@ -213,7 +213,7 @@ static void mark_results_over(DB_HOST& host) { // Some special cases: // 1) If no host ID is supplied, or if RPC seqno mismatch, // create a new host record -// 2) If the host record specified by sreq.hostid is a "zombie" +// 2) If the host record specified by g_request->hostid is a "zombie" // (i.e. it was merged with another host via the web site) // then follow links to find the proper host // @@ -223,46 +223,46 @@ static void mark_results_over(DB_HOST& host) { // - reply.user contains a valid user record // - if user belongs to a team, reply.team contains team record // -int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +int authenticate_user() { int retval; char buf[256]; DB_HOST host; DB_USER user; DB_TEAM team; - if (sreq.hostid) { - retval = host.lookup_id(sreq.hostid); + if (g_request->hostid) { + retval = host.lookup_id(g_request->hostid); while (!retval && host.userid==0) { // if host record is zombie, follow link to new host // retval = host.lookup_id(host.rpc_seqno); if (!retval) { - reply.hostid = host.id; + g_reply->hostid = host.id; log_messages.printf(MSG_NORMAL, "[HOST#%d] forwarding to new host ID %d\n", - sreq.hostid, host.id + g_request->hostid, host.id ); } } if (retval) { USER_MESSAGE um("Can't find host record", "low"); - reply.insert_message(um); + g_reply->insert_message(um); log_messages.printf(MSG_NORMAL, "[HOST#%d?] can't find host\n", - sreq.hostid + g_request->hostid ); - sreq.hostid = 0; + g_request->hostid = 0; goto lookup_user_and_make_new_host; } - reply.host = host; + g_reply->host = host; // look up user based on the ID in host record, // and see if the authenticator matches (regular or weak) // sprintf(buf, "where id=%d", host.userid); retval = user.lookup(buf); - if (!retval && !strcmp(user.authenticator, sreq.authenticator)) { + if (!retval && !strcmp(user.authenticator, g_request->authenticator)) { // req auth matches user auth - go on } else { bool weak_auth = false; @@ -270,7 +270,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // user for host.userid exists - check weak auth // get_weak_auth(user, buf); - if (!strcmp(buf, sreq.authenticator)) { + if (!strcmp(buf, g_request->authenticator)) { weak_auth = true; log_messages.printf(MSG_DEBUG, "[HOST#%d] accepting weak authenticator\n", @@ -282,7 +282,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // weak auth failed - look up user based on authenticator // strlcpy( - user.authenticator, sreq.authenticator, sizeof(user.authenticator) + user.authenticator, g_request->authenticator, sizeof(user.authenticator) ); sprintf(buf, "where authenticator='%s'", user.authenticator); retval = user.lookup(buf); @@ -291,19 +291,19 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { "Detach and reattach to this project to fix this.", "high" ); - reply.insert_message(um); - reply.set_delay(DELAY_MISSING_KEY); - reply.nucleus_only = true; + g_reply->insert_message(um); + g_reply->set_delay(DELAY_MISSING_KEY); + g_reply->nucleus_only = true; log_messages.printf(MSG_CRITICAL, "[HOST#%d] [USER#%d] Bad authenticator '%s'\n", - host.id, user.id, sreq.authenticator + host.id, user.id, g_request->authenticator ); return ERR_AUTHENTICATOR; } } } - reply.user = user; + g_reply->user = user; if (host.userid != user.id) { // If the request's host ID isn't consistent with the authenticator, @@ -321,11 +321,11 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // the user must have copied the state file to a different host. // Make a new host record. // - if (!batch && sreq.rpc_seqno < reply.host.rpc_seqno) { - sreq.hostid = 0; + if (!batch && g_request->rpc_seqno < g_reply->host.rpc_seqno) { + g_request->hostid = 0; log_messages.printf(MSG_NORMAL, "[HOST#%d] [USER#%d] RPC seqno %d less than expected %d; creating new host\n", - reply.host.id, user.id, sreq.rpc_seqno, reply.host.rpc_seqno + g_reply->host.id, user.id, g_request->rpc_seqno, g_reply->host.rpc_seqno ); goto make_new_host; } @@ -337,18 +337,18 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { lookup_user_and_make_new_host: // if authenticator contains _, it's a weak auth // - if (strchr(sreq.authenticator, '_')) { - int userid = atoi(sreq.authenticator); + if (strchr(g_request->authenticator, '_')) { + int userid = atoi(g_request->authenticator); retval = user.lookup_id(userid); if (!retval) { get_weak_auth(user, buf); - if (strcmp(buf, sreq.authenticator)) { + if (strcmp(buf, g_request->authenticator)) { retval = ERR_AUTHENTICATOR; } } } else { strlcpy( - user.authenticator, sreq.authenticator, + user.authenticator, g_request->authenticator, sizeof(user.authenticator) ); sprintf(buf, "where authenticator='%s'", user.authenticator); @@ -360,15 +360,15 @@ lookup_user_and_make_new_host: "Detach and reattach to this project to fix this.", "low" ); - reply.insert_message(um); - reply.set_delay(DELAY_MISSING_KEY); + g_reply->insert_message(um); + g_reply->set_delay(DELAY_MISSING_KEY); log_messages.printf(MSG_CRITICAL, "[HOST#] Bad authenticator '%s': %d\n", - sreq.authenticator, retval + g_request->authenticator, retval ); return ERR_AUTHENTICATOR; } - reply.user = user; + g_reply->user = user; // If host CPID is present, // scan backwards through this user's hosts, @@ -377,8 +377,8 @@ lookup_user_and_make_new_host: // Use the existing host record, // and mark in-progress results as over. // - if (strlen(sreq.host.host_cpid)) { - if (find_host_by_cpid(user, sreq.host.host_cpid, host)) { + if (strlen(g_request->host.host_cpid)) { + if (find_host_by_cpid(user, g_request->host.host_cpid, host)) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] [USER#%d] User has another host with same CPID.\n", host.id, host.userid @@ -401,7 +401,7 @@ make_new_host: // NOTE: if the project allows multiple clients per host // (e.g. those that run on grids), skip this. // - if (!config.multiple_clients_per_host && find_host_by_other(user, sreq.host, host)) { + if (!config.multiple_clients_per_host && find_host_by_other(user, g_request->host, host)) { log_messages.printf(MSG_NORMAL, "[HOST#%d] [USER#%d] Found similar existing host for this user - assigned.\n", host.id, host.userid @@ -414,21 +414,21 @@ make_new_host: // or RPC seqno was too low. // // Create a new host. - // reply.user is filled in and valid at this point + // g_reply->user is filled in and valid at this point // - host = sreq.host; + host = g_request->host; host.id = 0; host.create_time = time(0); - host.userid = reply.user.id; + host.userid = g_reply->user.id; host.rpc_seqno = 0; host.expavg_time = time(0); host.error_rate = 0.1; - strcpy(host.venue, reply.user.venue); + strcpy(host.venue, g_reply->user.venue); host.fix_nans(); retval = host.insert(); if (retval) { USER_MESSAGE um("Couldn't create host record in database", "low"); - reply.insert_message(um); + g_reply->insert_message(um); boinc_db.print_error("host.insert()"); log_messages.printf(MSG_CRITICAL, "host.insert() failed\n"); return retval; @@ -436,39 +436,39 @@ make_new_host: host.id = boinc_db.insert_id(); got_host: - reply.host = host; - reply.hostid = reply.host.id; + g_reply->host = host; + g_reply->hostid = g_reply->host.id; // this tells client to updates its host ID - sreq.rpc_seqno = 0; + g_request->rpc_seqno = 0; // this value eventually gets written to host DB record; // for new hosts it must be zero. // This kludge forces this. } - // have user record in reply.user at this point + // have user record in g_reply->user at this point // - if (reply.user.teamid) { - retval = team.lookup_id(reply.user.teamid); - if (!retval) reply.team = team; + if (g_reply->user.teamid) { + retval = team.lookup_id(g_reply->user.teamid); + if (!retval) g_reply->team = team; } // compute email hash // md5_block( - (unsigned char*)reply.user.email_addr, - strlen(reply.user.email_addr), - reply.email_hash + (unsigned char*)g_reply->user.email_addr, + strlen(g_reply->user.email_addr), + g_reply->email_hash ); // if new user CPID, update user record // - if (strlen(sreq.cross_project_id)) { - if (strcmp(sreq.cross_project_id, reply.user.cross_project_id)) { - user.id = reply.user.id; - escape_string(sreq.cross_project_id, sizeof(sreq.cross_project_id)); - sprintf(buf, "cross_project_id='%s'", sreq.cross_project_id); - unescape_string(sreq.cross_project_id, sizeof(sreq.cross_project_id)); + if (strlen(g_request->cross_project_id)) { + if (strcmp(g_request->cross_project_id, g_reply->user.cross_project_id)) { + user.id = g_reply->user.id; + escape_string(g_request->cross_project_id, sizeof(g_request->cross_project_id)); + sprintf(buf, "cross_project_id='%s'", g_request->cross_project_id); + unescape_string(g_request->cross_project_id, sizeof(g_request->cross_project_id)); user.update_field(buf); } } @@ -607,44 +607,44 @@ static void compute_credit_rating(HOST& host) { // modify host struct based on request. // Copy all fields that are determined by the client. // -static int modify_host_struct(SCHEDULER_REQUEST& sreq, HOST& host) { - host.timezone = sreq.host.timezone; - strncpy(host.domain_name, sreq.host.domain_name, sizeof(host.domain_name)); - sreq.coprocs.summary_string(host.serialnum, sizeof(host.serialnum)); - if (strcmp(host.last_ip_addr, sreq.host.last_ip_addr)) { - strncpy(host.last_ip_addr, sreq.host.last_ip_addr, sizeof(host.last_ip_addr)); +static int modify_host_struct(HOST& host) { + host.timezone = g_request->host.timezone; + strncpy(host.domain_name, g_request->host.domain_name, sizeof(host.domain_name)); + g_request->coprocs.summary_string(host.serialnum, sizeof(host.serialnum)); + if (strcmp(host.last_ip_addr, g_request->host.last_ip_addr)) { + strncpy(host.last_ip_addr, g_request->host.last_ip_addr, sizeof(host.last_ip_addr)); } else { host.nsame_ip_addr++; } - host.on_frac = sreq.host.on_frac; - host.connected_frac = sreq.host.connected_frac; - host.active_frac = sreq.host.active_frac; - host.duration_correction_factor = sreq.host.duration_correction_factor; - host.p_ncpus = sreq.host.p_ncpus; - strncpy(host.p_vendor, sreq.host.p_vendor, sizeof(host.p_vendor)); + host.on_frac = g_request->host.on_frac; + host.connected_frac = g_request->host.connected_frac; + host.active_frac = g_request->host.active_frac; + host.duration_correction_factor = g_request->host.duration_correction_factor; + host.p_ncpus = g_request->host.p_ncpus; + strncpy(host.p_vendor, g_request->host.p_vendor, sizeof(host.p_vendor)); // unlikely this will change - strncpy(host.p_model, sreq.host.p_model, sizeof(host.p_model)); - host.p_fpops = sreq.host.p_fpops; - host.p_iops = sreq.host.p_iops; - host.p_membw = sreq.host.p_membw; - strncpy(host.os_name, sreq.host.os_name, sizeof(host.os_name)); - strncpy(host.os_version, sreq.host.os_version, sizeof(host.os_version)); - host.m_nbytes = sreq.host.m_nbytes; - host.m_cache = sreq.host.m_cache; - host.m_swap = sreq.host.m_swap; - host.d_total = sreq.host.d_total; - host.d_free = sreq.host.d_free; - host.d_boinc_used_total = sreq.host.d_boinc_used_total; - host.d_boinc_used_project = sreq.host.d_boinc_used_project; - host.n_bwup = sreq.host.n_bwup; - host.n_bwdown = sreq.host.n_bwdown; - if (strlen(sreq.host.host_cpid)) { - strcpy(host.host_cpid, sreq.host.host_cpid); + strncpy(host.p_model, g_request->host.p_model, sizeof(host.p_model)); + host.p_fpops = g_request->host.p_fpops; + host.p_iops = g_request->host.p_iops; + host.p_membw = g_request->host.p_membw; + strncpy(host.os_name, g_request->host.os_name, sizeof(host.os_name)); + strncpy(host.os_version, g_request->host.os_version, sizeof(host.os_version)); + host.m_nbytes = g_request->host.m_nbytes; + host.m_cache = g_request->host.m_cache; + host.m_swap = g_request->host.m_swap; + host.d_total = g_request->host.d_total; + host.d_free = g_request->host.d_free; + host.d_boinc_used_total = g_request->host.d_boinc_used_total; + host.d_boinc_used_project = g_request->host.d_boinc_used_project; + host.n_bwup = g_request->host.n_bwup; + host.n_bwdown = g_request->host.n_bwdown; + if (strlen(g_request->host.host_cpid)) { + strcpy(host.host_cpid, g_request->host.host_cpid); } host.fix_nans(); compute_credit_rating(host); - sreq.host.claimed_credit_per_cpu_sec = host.claimed_credit_per_cpu_sec; + g_request->host.claimed_credit_per_cpu_sec = host.claimed_credit_per_cpu_sec; return 0; } @@ -681,21 +681,21 @@ static int update_host_record(HOST& initial_host, HOST& xhost, USER& user) { // Figure out which of the results the host currently has // should be aborted outright, or aborted if not started yet // -int send_result_abort( SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +int send_result_abort() { int aborts_sent = 0; int retval = 0; DB_IN_PROGRESS_RESULT result; std::string result_names; unsigned int i; - if (sreq.other_results.size() == 0) { + if (g_request->other_results.size() == 0) { return 0; } // build list of result names // - for (i=0; iother_results.size(); i++) { + OTHER_RESULT& orp=g_request->other_results[i]; orp.abort = true; orp.abort_if_not_started = false; orp.reason = ABORT_REASON_NOT_FOUND; @@ -708,9 +708,9 @@ int send_result_abort( SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // look up selected fields from the results and their WUs, // and decide if they should be aborted // - while (!(retval = result.enumerate(reply.host.id, result_names.c_str()))) { - for (i=0; ihost.id, result_names.c_str()))) { + for (i=0; iother_results.size(); i++) { + OTHER_RESULT& orp = g_request->other_results[i]; if (!strcmp(orp.name.c_str(), result.result_name)) { if (result.error_mask&WU_ERROR_CANCELLED ) { // if the WU has been canceled, abort the result @@ -750,24 +750,24 @@ int send_result_abort( SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // loop through the results and send the appropriate message (if any) // - for (i=0; iother_results.size(); i++) { + OTHER_RESULT& orp = g_request->other_results[i]; if (orp.abort) { - reply.result_aborts.push_back(orp.name); + g_reply->result_aborts.push_back(orp.name); log_messages.printf(MSG_NORMAL, "[HOST#%d]: Send result_abort for result %s; reason %d\n", - reply.host.id, orp.name.c_str(), orp.reason + g_reply->host.id, orp.name.c_str(), orp.reason ); // send user message char buf[256]; sprintf(buf, "Result %s is no longer usable", orp.name.c_str()); USER_MESSAGE um(buf, "high"); - reply.insert_message(um); + g_reply->insert_message(um); } else if (orp.abort_if_not_started) { - reply.result_abort_if_not_starteds.push_back(orp.name); + g_reply->result_abort_if_not_starteds.push_back(orp.name); log_messages.printf(MSG_NORMAL, "[HOST#%d]: Send result_abort_if_unstarted for result %s; reason %d\n", - reply.host.id, orp.name.c_str(), orp.reason + g_reply->host.id, orp.name.c_str(), orp.reason ); } } @@ -779,26 +779,26 @@ int send_result_abort( SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // - from request msg // - from request message // - prefs from user DB record -// and parse them into sreq.global_prefs. +// and parse them into g_request->global_prefs. // 2) update prefs in user record if needed // 2) send global prefs in reply msg if needed // -int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +int handle_global_prefs() { char buf[BLOB_SIZE]; - reply.send_global_prefs = false; - bool have_working_prefs = (strlen(sreq.working_global_prefs_xml)>0); - bool have_master_prefs = (strlen(sreq.global_prefs_xml)>0); - bool have_db_prefs = (strlen(reply.user.global_prefs)>0); + g_reply->send_global_prefs = false; + bool have_working_prefs = (strlen(g_request->working_global_prefs_xml)>0); + bool have_master_prefs = (strlen(g_request->global_prefs_xml)>0); + bool have_db_prefs = (strlen(g_reply->user.global_prefs)>0); bool same_account = !strcmp( - sreq.global_prefs_source_email_hash, reply.email_hash + g_request->global_prefs_source_email_hash, g_reply->email_hash ); double master_mod_time=0, db_mod_time=0; if (have_master_prefs) { - parse_double(sreq.global_prefs_xml, "", master_mod_time); + parse_double(g_request->global_prefs_xml, "", master_mod_time); if (master_mod_time > dtime()) master_mod_time = dtime(); } if (have_db_prefs) { - parse_double(reply.user.global_prefs, "", db_mod_time); + parse_double(g_reply->user.global_prefs, "", db_mod_time); if (db_mod_time > dtime()) db_mod_time = dtime(); } @@ -810,34 +810,34 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { } // decide which prefs to use for sched decisions, - // and parse them into sreq.global_prefs + // and parse them into g_request->global_prefs // if (have_working_prefs) { - sreq.global_prefs.parse(sreq.working_global_prefs_xml, ""); + g_request->global_prefs.parse(g_request->working_global_prefs_xml, ""); if (config.debug_prefs) { log_messages.printf(MSG_DEBUG, "using working prefs\n"); } } else { if (have_master_prefs) { if (have_db_prefs && db_mod_time > master_mod_time) { - sreq.global_prefs.parse(reply.user.global_prefs, reply.host.venue); + g_request->global_prefs.parse(g_reply->user.global_prefs, g_reply->host.venue); if (config.debug_prefs) { log_messages.printf(MSG_DEBUG, "using db prefs - more recent\n"); } } else { - sreq.global_prefs.parse(sreq.global_prefs_xml, reply.host.venue); + g_request->global_prefs.parse(g_request->global_prefs_xml, g_reply->host.venue); if (config.debug_prefs) { log_messages.printf(MSG_DEBUG, "using master prefs\n"); } } } else { if (have_db_prefs) { - sreq.global_prefs.parse(reply.user.global_prefs, reply.host.venue); + g_request->global_prefs.parse(g_reply->user.global_prefs, g_reply->host.venue); if (config.debug_prefs) { log_messages.printf(MSG_DEBUG, "using db prefs\n"); } } else { - sreq.global_prefs.defaults(); + g_request->global_prefs.defaults(); if (config.debug_prefs) { log_messages.printf(MSG_DEBUG, "using default prefs\n"); } @@ -858,12 +858,12 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { } if (update_user_record) { log_messages.printf(MSG_DEBUG, "updating db prefs\n"); - strcpy(reply.user.global_prefs, sreq.global_prefs_xml); + strcpy(g_reply->user.global_prefs, g_request->global_prefs_xml); DB_USER user; - user.id = reply.user.id; - escape_string(sreq.global_prefs_xml, sizeof(sreq.global_prefs_xml)); - sprintf(buf, "global_prefs='%s'", sreq.global_prefs_xml); - unescape_string(sreq.global_prefs_xml, sizeof(sreq.global_prefs_xml)); + user.id = g_reply->user.id; + escape_string(g_request->global_prefs_xml, sizeof(g_request->global_prefs_xml)); + sprintf(buf, "global_prefs='%s'", g_request->global_prefs_xml); + unescape_string(g_request->global_prefs_xml, sizeof(g_request->global_prefs_xml)); int retval = user.update_field(buf); if (retval) { log_messages.printf(MSG_CRITICAL, @@ -878,14 +878,14 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (config.debug_prefs) { log_messages.printf(MSG_DEBUG, "have db %d; dbmod %f; global mod %f\n", - have_db_prefs, db_mod_time, sreq.global_prefs.mod_time + have_db_prefs, db_mod_time, g_request->global_prefs.mod_time ); } if (have_db_prefs && db_mod_time > master_mod_time) { if (config.debug_prefs) { log_messages.printf(MSG_DEBUG, "sending db prefs in reply\n"); } - reply.send_global_prefs = true; + g_reply->send_global_prefs = true; } return 0; } @@ -894,15 +894,13 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // send it the new one, with a signature based on the old one. // If they don't have a code sign key, send them one // -bool send_code_sign_key( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, char* code_sign_key -) { +bool send_code_sign_key(char* code_sign_key) { char* oldkey, *signature; int i, retval; char path[256]; - if (strlen(sreq.code_sign_key)) { - if (strcmp(sreq.code_sign_key, code_sign_key)) { + if (strlen(g_request->code_sign_key)) { + if (strcmp(g_request->code_sign_key, code_sign_key)) { log_messages.printf(MSG_NORMAL, "received old code sign key\n"); // look for a signature file @@ -917,10 +915,10 @@ bool send_code_sign_key( "If the problem persists, detach/attach the project. ", "high" ); - reply.insert_message(um); + g_reply->insert_message(um); return false; } - if (!strcmp(oldkey, sreq.code_sign_key)) { + if (!strcmp(oldkey, g_request->code_sign_key)) { sprintf(path, "%s/signature_%d", config.key_dir, i); retval = read_file_malloc(path, signature); if (retval) { @@ -930,10 +928,10 @@ bool send_code_sign_key( "If the problem persists, detach/attach the project. ", "high" ); - reply.insert_message(um); + g_reply->insert_message(um); } else { - safe_strcpy(reply.code_sign_key, code_sign_key); - safe_strcpy(reply.code_sign_key_signature, signature); + safe_strcpy(g_reply->code_sign_key, code_sign_key); + safe_strcpy(g_reply->code_sign_key_signature, signature); free(signature); } } @@ -942,7 +940,7 @@ bool send_code_sign_key( } } } else { - safe_strcpy(reply.code_sign_key, code_sign_key); + safe_strcpy(g_reply->code_sign_key, code_sign_key); } return true; } @@ -953,10 +951,8 @@ bool send_code_sign_key( // given in in Unix time(2) format // expires. // -void warn_user_if_core_client_upgrade_scheduled( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { - if (sreq.core_client_version < config.min_core_client_version_announced) { +void warn_user_if_core_client_upgrade_scheduled() { + if (g_request->core_client_version < config.min_core_client_version_announced) { // time remaining in hours, before upgrade required int remaining = config.min_core_client_upgrade_deadline-time(0); @@ -975,25 +971,25 @@ void warn_user_if_core_client_upgrade_scheduled( days, hours, config.min_core_client_version_announced / 100, config.min_core_client_version_announced % 100, - sreq.core_client_major_version, - sreq.core_client_minor_version, - sreq.core_client_release + g_request->core_client_major_version, + g_request->core_client_minor_version, + g_request->core_client_release ); // make this low priority until three days are left. Then // bump to high. // if (days<3) { USER_MESSAGE um(msg, "high"); - reply.insert_message(um); + g_reply->insert_message(um); } else { USER_MESSAGE um(msg, "low"); - reply.insert_message(um); + g_reply->insert_message(um); } log_messages.printf(MSG_DEBUG, "Sending warning: upgrade client %d.%d.%d within %d days %d hours\n", - sreq.core_client_major_version, - sreq.core_client_minor_version, - sreq.core_client_release, + g_request->core_client_major_version, + g_request->core_client_minor_version, + g_request->core_client_release, days, hours ); } @@ -1001,89 +997,83 @@ void warn_user_if_core_client_upgrade_scheduled( return; } -bool unacceptable_os( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { +bool unacceptable_os() { unsigned int i; char buf[1024]; for (i=0; isize(); i++) { regex_t& re = (*config.ban_os)[i]; - strcpy(buf, sreq.host.os_name); + strcpy(buf, g_request->host.os_name); strcat(buf, "\t"); - strcat(buf, sreq.host.os_version); + strcat(buf, g_request->host.os_version); if (!regexec(&re, buf, 0, NULL, 0)) { log_messages.printf(MSG_NORMAL, "Unacceptable OS %s %s\n", - sreq.host.os_name, sreq.host.os_version + g_request->host.os_name, g_request->host.os_version ); sprintf(buf, "This project doesn't support OS type %s %s", - sreq.host.os_name, sreq.host.os_version + g_request->host.os_name, g_request->host.os_version ); USER_MESSAGE um(buf, "low"); - reply.insert_message(um); - reply.set_delay(DELAY_UNACCEPTABLE_OS); + g_reply->insert_message(um); + g_reply->set_delay(DELAY_UNACCEPTABLE_OS); return true; } } return false; } -bool unacceptable_cpu( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { +bool unacceptable_cpu() { unsigned int i; char buf[1024]; for (i=0; isize(); i++) { regex_t& re = (*config.ban_cpu)[i]; - strcpy(buf, sreq.host.p_vendor); + strcpy(buf, g_request->host.p_vendor); strcat(buf, "\t"); - strcat(buf, sreq.host.p_model); + strcat(buf, g_request->host.p_model); if (!regexec(&re, buf, 0, NULL, 0)) { log_messages.printf(MSG_NORMAL, "Unacceptable CPU %s %s\n", - sreq.host.p_vendor, sreq.host.p_model + g_request->host.p_vendor, g_request->host.p_model ); sprintf(buf, "This project doesn't support CPU type %s %s", - sreq.host.p_vendor, sreq.host.p_model + g_request->host.p_vendor, g_request->host.p_model ); USER_MESSAGE um(buf, "low"); - reply.insert_message(um); - reply.set_delay(DELAY_UNACCEPTABLE_OS); + g_reply->insert_message(um); + g_reply->set_delay(DELAY_UNACCEPTABLE_OS); return true; } } return false; } -bool wrong_core_client_version( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { +bool wrong_core_client_version() { char msg[256]; bool wrong_version = false; if (config.min_core_client_version) { int major = config.min_core_client_version/100; int minor = config.min_core_client_version % 100; - if (sreq.core_client_major_version < major || - ((sreq.core_client_major_version == major) && (sreq.core_client_minor_version < minor))) { + if (g_request->core_client_major_version < major || + ((g_request->core_client_major_version == major) && (g_request->core_client_minor_version < minor))) { wrong_version = true; sprintf(msg, "Need version %d.%d or higher of the BOINC core client. You have %d.%d.", major, minor, - sreq.core_client_major_version, sreq.core_client_minor_version + g_request->core_client_major_version, g_request->core_client_minor_version ); log_messages.printf(MSG_NORMAL, "[HOST#%d] [auth %s] Wrong minor version from user: wanted %d, got %d\n", - sreq.hostid, sreq.authenticator, - minor, sreq.core_client_minor_version + g_request->hostid, g_request->authenticator, + minor, g_request->core_client_minor_version ); } } if (wrong_version) { USER_MESSAGE um(msg, "low"); - reply.insert_message(um); - reply.set_delay(DELAY_BAD_CLIENT_VERSION); + g_reply->insert_message(um); + g_reply->set_delay(DELAY_BAD_CLIENT_VERSION); return true; } return false; @@ -1094,18 +1084,18 @@ inline static const char* get_remote_addr() { return r ? r : "?.?.?.?"; } -void handle_msgs_from_host(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +void handle_msgs_from_host() { unsigned int i; DB_MSG_FROM_HOST mfh; int retval; - for (i=0; imsgs_from_host.size(); i++) { + g_reply->send_msg_ack = true; + MSG_FROM_HOST_DESC& md = g_request->msgs_from_host[i]; mfh.clear(); mfh.create_time = time(0); safe_strcpy(mfh.variety, md.variety); - mfh.hostid = reply.host.id; + mfh.hostid = g_reply->host.id; mfh.handled = false; safe_strcpy(mfh.xml, md.msg_text.c_str()); log_messages.printf(MSG_NORMAL, @@ -1116,9 +1106,9 @@ void handle_msgs_from_host(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (retval) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] message insert failed: %d\n", - reply.host.id, retval + g_reply->host.id, retval ); - reply.send_msg_ack = false; + g_reply->send_msg_ack = false; // may as well return; if one insert failed, others will too // @@ -1127,58 +1117,59 @@ void handle_msgs_from_host(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { } } -void handle_msgs_to_host(SCHEDULER_REPLY& reply) { +void handle_msgs_to_host() { DB_MSG_TO_HOST mth; char buf[256]; - sprintf(buf, "where hostid = %d and handled = %d", reply.host.id, 0); + sprintf(buf, "where hostid = %d and handled = %d", g_reply->host.id, 0); while (!mth.enumerate(buf)) { - reply.msgs_to_host.push_back(mth); + g_reply->msgs_to_host.push_back(mth); mth.handled = true; mth.update(); } } -static void log_request(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +static void log_request() { log_messages.printf(MSG_NORMAL, "Request: [USER#%d] [HOST#%d] [IP %s] client %d.%d.%d, work req %d sec\n", - reply.user.id, reply.host.id, get_remote_addr(), - sreq.core_client_major_version, sreq.core_client_minor_version, - sreq.core_client_release, - (int)sreq.work_req_seconds + g_reply->user.id, g_reply->host.id, get_remote_addr(), + g_request->core_client_major_version, + g_request->core_client_minor_version, + g_request->core_client_release, + (int)g_request->work_req_seconds ); if (config.debug_request_details) { log_messages.printf(MSG_DEBUG, "Request details: auth %s, RPC seqno %d, platform %s\n", - sreq.authenticator, sreq.rpc_seqno, sreq.platform.name + g_request->authenticator, + g_request->rpc_seqno, + g_request->platform.name ); } log_messages.set_indent_level(2); } -bool bad_install_type(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +bool bad_install_type() { if (config.no_vista_sandbox) { - if (!strcmp(sreq.host.os_name, "Microsoft Windows Vista")) { - if (sreq.sandbox == 1) { + if (!strcmp(g_request->host.os_name, "Microsoft Windows Vista")) { + if (g_request->sandbox == 1) { log_messages.printf(MSG_INFO, "Vista secure install - not sending work\n" ); USER_MESSAGE um( "Unable to send work to Vista with BOINC installed in protected mode", "high" ); - reply.insert_message(um); + g_reply->insert_message(um); USER_MESSAGE um2( "Please reinstall BOINC and uncheck 'Protected application execution'", "high" ); - reply.insert_message(um2); + g_reply->insert_message(um2); } } } return false; } -void process_request( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, char* code_sign_key -) { +void process_request(char* code_sign_key) { PLATFORM* platform; int retval; double last_rpc_time; @@ -1192,23 +1183,23 @@ void process_request( unsigned int i; time_t t; - memset(&reply.wreq, 0, sizeof(reply.wreq)); + memset(&g_reply->wreq, 0, sizeof(g_reply->wreq)); // if different major version of BOINC, just send a message // - if (wrong_core_client_version(sreq, reply) - || unacceptable_os(sreq, reply) - || unacceptable_cpu(sreq, reply) + if (wrong_core_client_version() + || unacceptable_os() + || unacceptable_cpu() ) { ok_to_send_work = false; // if no results, return without accessing DB // - if (sreq.results.size() == 0) { + if (g_request->results.size() == 0) { return; } } else { - warn_user_if_core_client_upgrade_scheduled(sreq, reply); + warn_user_if_core_client_upgrade_scheduled(); } if (config.locality_scheduling || config.enable_assignment) { @@ -1225,14 +1216,14 @@ void process_request( // if ( config.nowork_skip - && (sreq.work_req_seconds > 0) + && (g_request->work_req_seconds > 0) && have_no_work - && (sreq.results.size() == 0) - && (sreq.hostid != 0) + && (g_request->results.size() == 0) + && (g_request->hostid != 0) ) { USER_MESSAGE um("No work available", "low"); - reply.insert_message(um); - reply.set_delay(DELAY_NO_WORK_SKIP); + g_reply->insert_message(um); + g_reply->set_delay(DELAY_NO_WORK_SKIP); if (!config.msg_to_host) { log_messages.printf(MSG_NORMAL, "No work - skipping DB access\n"); return; @@ -1246,34 +1237,32 @@ void process_request( // retval = open_database(); if (retval) { - send_error_message(reply, "Server can't open database", 3600); - reply.project_is_down = true; + send_error_message("Server can't open database", 3600); + g_reply->project_is_down = true; goto leave; } - retval = authenticate_user(sreq, reply); + retval = authenticate_user(); if (retval) goto leave; - if (reply.user.id == 0) { + if (g_reply->user.id == 0) { log_messages.printf(MSG_CRITICAL, "No user ID!\n"); } - initial_host = reply.host; - reply.host.rpc_seqno = sreq.rpc_seqno; + initial_host = g_reply->host; + g_reply->host.rpc_seqno = g_request->rpc_seqno; - reply.nucleus_only = false; + g_reply->nucleus_only = false; - log_request(sreq, reply); + log_request(); // is host blacklisted? // - if (reply.host.max_results_day == -1) { - send_error_message( - reply, "Not accepting requests from this host", 86400 - ); + if (g_reply->host.max_results_day == -1) { + send_error_message("Not accepting requests from this host", 86400); goto leave; } if (strlen(config.sched_lockfile_dir)) { - int pid_with_lock = lock_sched(reply); + int pid_with_lock = lock_sched(); if (pid_with_lock > 0) { log_messages.printf(MSG_CRITICAL, "Another scheduler instance [PID=%d] is running for this host\n", @@ -1281,100 +1270,100 @@ void process_request( ); } else if (pid_with_lock) { log_messages.printf(MSG_CRITICAL, - "Error acquiring lock for [HOST#%d]\n", reply.host.id + "Error acquiring lock for [HOST#%d]\n", g_reply->host.id ); } if (pid_with_lock) { send_error_message( - reply, "Another scheduler instance is running for this host", 60 + "Another scheduler instance is running for this host", 60 ); goto leave; } } - last_rpc_time = reply.host.rpc_time; - t = reply.host.rpc_time; + last_rpc_time = g_reply->host.rpc_time; + t = g_reply->host.rpc_time; rpc_time_tm = localtime(&t); last_rpc_dayofyear = rpc_time_tm->tm_yday; t = time(0); - reply.host.rpc_time = t; + g_reply->host.rpc_time = t; rpc_time_tm = localtime(&t); current_rpc_dayofyear = rpc_time_tm->tm_yday; if (config.daily_result_quota) { - if (reply.host.max_results_day == 0 || reply.host.max_results_day > config.daily_result_quota) { - reply.host.max_results_day = config.daily_result_quota; + if (g_reply->host.max_results_day == 0 || g_reply->host.max_results_day > config.daily_result_quota) { + g_reply->host.max_results_day = config.daily_result_quota; log_messages.printf(MSG_DEBUG, "[HOST#%d] Initializing max_results_day to %d\n", - reply.host.id, config.daily_result_quota + g_reply->host.id, config.daily_result_quota ); } } if (last_rpc_dayofyear != current_rpc_dayofyear) { log_messages.printf(MSG_DEBUG, - "[HOST#%d] Resetting nresults_today\n", reply.host.id + "[HOST#%d] Resetting nresults_today\n", g_reply->host.id ); - reply.host.nresults_today = 0; + g_reply->host.nresults_today = 0; } - retval = modify_host_struct(sreq, reply.host); + retval = modify_host_struct(g_reply->host); // write time stats to disk if present // - if (sreq.have_time_stats_log) { - write_time_stats_log(reply); + if (g_request->have_time_stats_log) { + write_time_stats_log(); } // look up the client's platform(s) in the DB // - platform = ssp->lookup_platform(sreq.platform.name); - if (platform) sreq.platforms.list.push_back(platform); - for (i=0; ilookup_platform(sreq.alt_platforms[i].name); - if (platform) sreq.platforms.list.push_back(platform); + platform = ssp->lookup_platform(g_request->platform.name); + if (platform) g_request->platforms.list.push_back(platform); + for (i=0; ialt_platforms.size(); i++) { + platform = ssp->lookup_platform(g_request->alt_platforms[i].name); + if (platform) g_request->platforms.list.push_back(platform); } - if (sreq.platforms.list.size() == 0) { - sprintf(buf, "platform '%s' not found", sreq.platform.name); + if (g_request->platforms.list.size() == 0) { + sprintf(buf, "platform '%s' not found", g_request->platform.name); USER_MESSAGE um(buf, "low"); - reply.insert_message(um); + g_reply->insert_message(um); log_messages.printf(MSG_CRITICAL, "[HOST#%d] platform '%s' not found\n", - reply.host.id, sreq.platform.name + g_reply->host.id, g_request->platform.name ); - reply.set_delay(DELAY_PLATFORM_UNSUPPORTED); + g_reply->set_delay(DELAY_PLATFORM_UNSUPPORTED); goto leave; } - handle_global_prefs(sreq, reply); + handle_global_prefs(); - handle_results(sreq, reply); + handle_results(); // Do this before resending lost jobs // - if (bad_install_type(sreq, reply)) { + if (bad_install_type()) { ok_to_send_work = false; } - reply.wreq.nresults_on_host = sreq.other_results.size(); - if (sreq.have_other_results_list) { + g_reply->wreq.nresults_on_host = g_request->other_results.size(); + if (g_request->have_other_results_list) { if (config.resend_lost_results && ok_to_send_work) { - if (resend_lost_work(sreq, reply)) { + if (resend_lost_work()) { ok_to_send_work = false; } } if (config.send_result_abort) { - send_result_abort(sreq, reply); + send_result_abort(); } } - if (!send_code_sign_key(sreq, reply, code_sign_key)) { + if (!send_code_sign_key(code_sign_key)) { ok_to_send_work = false; } // if last RPC was within config.min_sendwork_interval, don't send work // - if (!have_no_work && ok_to_send_work && sreq.work_req_seconds > 0) { + if (!have_no_work && ok_to_send_work && g_request->work_req_seconds > 0) { if (config.min_sendwork_interval) { double diff = dtime() - last_rpc_time; if (diff < config.min_sendwork_interval) { @@ -1386,12 +1375,12 @@ void process_request( "Not sending work - last request too recent: %d sec", (int)diff ); USER_MESSAGE um(buf, "low"); - reply.insert_message(um); + g_reply->insert_message(um); // the 1.01 is in case client's clock // is slightly faster than ours // - reply.set_delay(1.01*config.min_sendwork_interval); + g_reply->set_delay(1.01*config.min_sendwork_interval); } } if (ok_to_send_work) { @@ -1400,12 +1389,12 @@ void process_request( } - handle_msgs_from_host(sreq, reply); + handle_msgs_from_host(); if (config.msg_to_host) { - handle_msgs_to_host(reply); + handle_msgs_to_host(); } - update_host_record(initial_host, reply.host, reply.user); + update_host_record(initial_host, g_reply->host, g_reply->user); leave: if (!have_no_work) { @@ -1413,7 +1402,7 @@ leave: } } -static void log_incomplete_request(SCHEDULER_REQUEST& sreq) { +static void log_incomplete_request() { // BOINC scheduler requests use method POST. // So method GET means that someone is trying a browser. // @@ -1425,17 +1414,17 @@ static void log_incomplete_request(SCHEDULER_REQUEST& sreq) { log_messages.printf(MSG_NORMAL, "Incomplete request received %sfrom IP %s, auth %s, platform %s, version %d.%d.%d\n", used_get?"(used GET method - probably a browser) ":"", - get_remote_addr(), sreq.authenticator, sreq.platform.name, - sreq.core_client_major_version, sreq.core_client_minor_version, - sreq.core_client_release + get_remote_addr(), g_request->authenticator, g_request->platform.name, + g_request->core_client_major_version, g_request->core_client_minor_version, + g_request->core_client_release ); } -static void log_user_messages(SCHEDULER_REPLY& sreply) { - for (unsigned int i=0; imessages.size(); i++) { + USER_MESSAGE um = g_reply->messages[i]; log_messages.printf(MSG_DEBUG, - "[HOST#%d] MSG(%4s) %s \n", sreply.host.id, um.priority.c_str(), um.message.c_str() + "[HOST#%d] MSG(%4s) %s \n", g_reply->host.id, um.priority.c_str(), um.message.c_str() ); } } @@ -1456,26 +1445,26 @@ void handle_request(FILE* fin, FILE* fout, char* code_sign_key) { const char* p = sreq.parse(fin); if (!p){ - process_request(sreq, sreply, code_sign_key); + process_request(code_sign_key); } else { sprintf(buf, "Error in request message: %s", p); - log_incomplete_request(sreq); + log_incomplete_request(); USER_MESSAGE um(buf, "low"); sreply.insert_message(um); } if (config.locality_scheduling && !sreply.nucleus_only) { - send_file_deletes(sreq, sreply); + send_file_deletes(); } if (config.debug_user_messages) { - log_user_messages(sreply); + log_user_messages(); } sreply.write(fout, sreq); if (strlen(config.sched_lockfile_dir)) { - unlock_sched(sreply); + unlock_sched(); } } diff --git a/sched/main.cpp b/sched/main.cpp index 825a3dddcb..dd0a1c0bc2 100644 --- a/sched/main.cpp +++ b/sched/main.cpp @@ -97,9 +97,7 @@ static void usage(char* p) { exit(1); } -void debug_sched( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& sreply, const char *trigger -) { +void debug_sched(const char *trigger) { char tmpfilename[256]; #ifndef _USING_FCGI_ FILE *fp; @@ -111,7 +109,9 @@ void debug_sched( return; } - sprintf(tmpfilename, "sched_reply_%06d_%06d", sreq.hostid, sreq.rpc_seqno); + sprintf(tmpfilename, + "sched_reply_%06d_%06d", g_request->hostid, g_request->rpc_seqno + ); // use _XXXXXX if you want random filenames rather than // deterministic mkstemp(tmpfilename); @@ -132,10 +132,12 @@ void debug_sched( "Found %s, so writing %s\n", trigger, tmpfilename ); - sreply.write(fp, sreq); + g_reply->write(fp, *g_request); fclose(fp); - sprintf(tmpfilename, "sched_request_%06d_%06d", sreq.hostid, sreq.rpc_seqno); + sprintf(tmpfilename, + "sched_request_%06d_%06d", g_request->hostid, g_request->rpc_seqno + ); #ifndef _USING_FCGI_ fp=fopen(tmpfilename, "w"); #else @@ -153,7 +155,7 @@ void debug_sched( "Found %s, so writing %s\n", trigger, tmpfilename ); - sreq.write(fp); + g_request->write(fp); fclose(fp); return; diff --git a/sched/main.h b/sched/main.h index 2683c56d03..e4816202e8 100644 --- a/sched/main.h +++ b/sched/main.h @@ -69,6 +69,4 @@ extern bool mark_jobs_done; // (for debugging/testing) extern int open_database(); -extern void debug_sched( - SCHEDULER_REQUEST&, SCHEDULER_REPLY&, const char *trigger -); +extern void debug_sched(const char *trigger); diff --git a/sched/sched_array.cpp b/sched/sched_array.cpp index 39ad70dae2..d6754f0519 100644 --- a/sched/sched_array.cpp +++ b/sched/sched_array.cpp @@ -39,10 +39,10 @@ #endif // Make a pass through the wu/results array, sending work. -// If reply.wreq.infeasible_only is true, +// If g_wreq->infeasible_only is true, // send only results that were previously infeasible for some host // -void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +void scan_work_array() { int i, j, retval, n, rnd_off, last_retval=0;; WORKUNIT wu; DB_RESULT result; @@ -54,7 +54,7 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { rnd_off = rand() % ssp->max_wu_results; for (j=0; jmax_wu_results; j++) { i = (j+rnd_off) % ssp->max_wu_results; - if (!work_needed(sreq, reply, false)) break; + if (!work_needed(false)) break; WU_RESULT& wu_result = ssp->wu_results[i]; @@ -71,13 +71,13 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // app = ssp->lookup_app(wu_result.workunit.appid); if (app == NULL) continue; // this should never happen - if (reply.wreq.beta_only) { + if (g_wreq->beta_only) { if (!app->beta) { continue; } log_messages.printf(MSG_DEBUG, "[HOST#%d] beta work found. [RESULT#%d]\n", - reply.host.id, wu_result.resultid + g_reply->host.id, wu_result.resultid ); } else { if (app->beta) { @@ -90,9 +90,9 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // skip if the app is beta (beta apps don't use the reliable mechanism) // if (!app->beta) { - if (reply.wreq.reliable_only && (!wu_result.need_reliable)) { + if (g_wreq->reliable_only && (!wu_result.need_reliable)) { continue; - } else if (!reply.wreq.reliable_only && wu_result.need_reliable) { + } else if (!g_wreq->reliable_only && wu_result.need_reliable) { continue; } } @@ -100,7 +100,7 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // don't send if we are looking for infeasible results // and the result is not infeasible // - if (reply.wreq.infeasible_only && (wu_result.infeasible_count==0)) { + if (g_wreq->infeasible_only && (wu_result.infeasible_count==0)) { continue; } @@ -108,15 +108,15 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // check app filter if needed // - if (reply.wreq.user_apps_only && - (!reply.wreq.beta_only || config.distinct_beta_apps) + if (g_wreq->user_apps_only && + (!g_wreq->beta_only || config.distinct_beta_apps) ) { if (app_not_selected(wu)) { - reply.wreq.no_allowed_apps_available = true; + g_wreq->no_allowed_apps_available = true; if (config.debug_send) { log_messages.printf(MSG_DEBUG, "[USER#%d] [WU#%d] user doesn't want work for this application\n", - reply.user.id, wu.id + g_reply->user.id, wu.id ); } continue; @@ -138,7 +138,7 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (retval != last_retval && config.debug_send) { log_messages.printf(MSG_DEBUG, "[HOST#%d] [WU#%d %s] WU is infeasible: %s\n", - reply.host.id, wu.id, wu.name, infeasible_string(retval) + g_reply->host.id, wu.id, wu.name, infeasible_string(retval) ); } last_retval = retval; @@ -162,7 +162,7 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (config.one_result_per_user_per_wu) { sprintf(buf, "where workunitid=%d and userid=%d", - wu_result.workunit.id, reply.user.id + wu_result.workunit.id, g_reply->user.id ); retval = result.count(n, buf); if (retval) { @@ -174,7 +174,7 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (n>0) { log_messages.printf(MSG_DEBUG, "send_work: user %d already has %d result(s) for WU %d\n", - reply.user.id, n, wu_result.workunit.id + g_reply->user.id, n, wu_result.workunit.id ); goto dont_send; } @@ -187,7 +187,7 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // sprintf(buf, "where workunitid=%d and hostid=%d", - wu_result.workunit.id, reply.host.id + wu_result.workunit.id, g_reply->host.id ); retval = result.count(n, buf); if (retval) { @@ -199,7 +199,7 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (n>0) { log_messages.printf(MSG_DEBUG, "send_work: host %d already has %d result(s) for WU %d\n", - reply.host.id, n, wu_result.workunit.id + g_reply->host.id, n, wu_result.workunit.id ); goto dont_send; } @@ -208,11 +208,11 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (app_hr_type(*app)) { if (already_sent_to_different_platform_careful( - sreq, reply.wreq, wu_result.workunit, *app + wu_result.workunit, *app )) { log_messages.printf(MSG_DEBUG, "[HOST#%d] [WU#%d %s] WU is infeasible (assigned to different platform)\n", - reply.host.id, wu.id, wu.name + g_reply->host.id, wu.id, wu.name ); // Mark the workunit as infeasible. // This ensures that jobs already assigned to a platform diff --git a/sched/sched_array.h b/sched/sched_array.h index 0e1843e5b9..b2e7ed1b28 100644 --- a/sched/sched_array.h +++ b/sched/sched_array.h @@ -15,4 +15,4 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -extern void scan_work_array(SCHEDULER_REQUEST&, SCHEDULER_REPLY&); +extern void scan_work_array(); diff --git a/sched/sched_assign.cpp b/sched/sched_assign.cpp index 00f25e51fa..3fb13bc311 100644 --- a/sched/sched_assign.cpp +++ b/sched/sched_assign.cpp @@ -29,9 +29,7 @@ #include "sched_assign.h" -static int send_assigned_job( - ASSIGNMENT& asg, SCHEDULER_REQUEST& request, SCHEDULER_REPLY& reply -) { +static int send_assigned_job(ASSIGNMENT& asg) { int retval; DB_WORKUNIT wu; char rtfpath[256], suffix[256], path[256], buf[256]; @@ -99,7 +97,7 @@ static int send_assigned_job( if (config.debug_assignment) { log_messages.printf(MSG_DEBUG, "[WU#%d] [RESULT#%d] [HOST#%d] send assignment %d\n", - wu.id, result_id, reply.host.id, asg.id + wu.id, result_id, g_reply->host.id, asg.id ); } return 0; @@ -108,7 +106,7 @@ static int send_assigned_job( // Send this host any jobs assigned to it, or to its user/team // Return true iff we sent anything // -bool send_assigned_jobs(SCHEDULER_REQUEST& request, SCHEDULER_REPLY& reply) { +bool send_assigned_jobs() { DB_RESULT result; int retval; char buf[256]; @@ -128,46 +126,46 @@ bool send_assigned_jobs(SCHEDULER_REQUEST& request, SCHEDULER_REPLY& reply) { switch (asg.target_type) { case ASSIGN_NONE: sprintf(buf, "where hostid=%d and workunitid=%d", - reply.host.id, asg.workunitid + g_reply->host.id, asg.workunitid ); retval = result.lookup(buf); if (retval == ERR_DB_NOT_FOUND) { - retval = send_assigned_job(asg, request, reply); + retval = send_assigned_job(asg); if (!retval) sent_something = true; } break; case ASSIGN_HOST: - if (reply.host.id != asg.target_id) continue; + if (g_reply->host.id != asg.target_id) continue; sprintf(buf, "where workunitid=%d", asg.workunitid); retval = result.lookup(buf); if (retval == ERR_DB_NOT_FOUND) { - retval = send_assigned_job(asg, request, reply); + retval = send_assigned_job(asg); if (!retval) sent_something = true; } break; case ASSIGN_USER: - if (reply.user.id != asg.target_id) continue; + if (g_reply->user.id != asg.target_id) continue; if (asg.multi) { - sprintf(buf, "where workunitid=%d and hostid=%d", asg.workunitid, reply.host.id); + sprintf(buf, "where workunitid=%d and hostid=%d", asg.workunitid, g_reply->host.id); } else { sprintf(buf, "where workunitid=%d", asg.workunitid); } retval = result.lookup(buf); if (retval == ERR_DB_NOT_FOUND) { - retval = send_assigned_job(asg, request, reply); + retval = send_assigned_job(asg); if (!retval) sent_something = true; } break; case ASSIGN_TEAM: - if (reply.team.id != asg.target_id) continue; + if (g_reply->team.id != asg.target_id) continue; if (asg.multi) { - sprintf(buf, "where workunitid=%d and hostid=%d", asg.workunitid, reply.host.id); + sprintf(buf, "where workunitid=%d and hostid=%d", asg.workunitid, g_reply->host.id); } else { sprintf(buf, "where workunitid=%d", asg.workunitid); } retval = result.lookup(buf); if (retval == ERR_DB_NOT_FOUND) { - retval = send_assigned_job(asg, request, reply); + retval = send_assigned_job(asg); if (!retval) sent_something = true; } break; diff --git a/sched/sched_assign.h b/sched/sched_assign.h index 8f1dd5bf23..3ad1519fea 100644 --- a/sched/sched_assign.h +++ b/sched/sched_assign.h @@ -15,4 +15,4 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -extern bool send_assigned_jobs(SCHEDULER_REQUEST&, SCHEDULER_REPLY&); +extern bool send_assigned_jobs(); diff --git a/sched/sched_hr.cpp b/sched/sched_hr.cpp index 0cc396a1f0..7faf395051 100644 --- a/sched/sched_hr.cpp +++ b/sched/sched_hr.cpp @@ -50,10 +50,8 @@ bool hr_unknown_platform(HOST& host) { // quick check for platform compatibility // -bool already_sent_to_different_platform_quick( - SCHEDULER_REQUEST& sreq, WORKUNIT& wu, APP& app -) { - if (wu.hr_class && (hr_class(sreq.host, app_hr_type(app)) != wu.hr_class)) { +bool already_sent_to_different_platform_quick(WORKUNIT& wu, APP& app) { + if (wu.hr_class && (hr_class(g_request->host, app_hr_type(app)) != wu.hr_class)) { return true; } return false; @@ -69,9 +67,7 @@ bool already_sent_to_different_platform_quick( // // This is "careful" in that it rereads the WU from DB // -bool already_sent_to_different_platform_careful( - SCHEDULER_REQUEST& sreq, WORK_REQ& wreq, WORKUNIT& workunit, APP& app -) { +bool already_sent_to_different_platform_careful(WORKUNIT& workunit, APP& app) { DB_WORKUNIT db_wu; int retval, wu_hr_class; char buf[256], buf2[256]; @@ -87,11 +83,11 @@ bool already_sent_to_different_platform_careful( ); return true; } - wreq.hr_reject_temp = false; - int host_hr_class = hr_class(sreq.host, app_hr_type(app)); + g_wreq->hr_reject_temp = false; + int host_hr_class = hr_class(g_request->host, app_hr_type(app)); if (wu_hr_class) { if (host_hr_class != wu_hr_class) { - wreq.hr_reject_temp = true; + g_wreq->hr_reject_temp = true; } } else { // do a "careful update" to make sure the WU's hr_class hasn't @@ -103,7 +99,7 @@ bool already_sent_to_different_platform_careful( if (retval) return true; if (boinc_db.affected_rows() != 1) return true; } - return wreq.hr_reject_temp; + return g_wreq->hr_reject_temp; } const char *BOINC_RCSID_4196d9a5b4="$Id$"; diff --git a/sched/sched_hr.h b/sched/sched_hr.h index defe3559ad..621b99a194 100644 --- a/sched/sched_hr.h +++ b/sched/sched_hr.h @@ -15,12 +15,10 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -extern bool already_sent_to_different_platform_quick( - SCHEDULER_REQUEST& sreq, WORKUNIT&, APP& -); +extern bool already_sent_to_different_platform_quick(WORKUNIT&, APP&); extern bool already_sent_to_different_platform_careful( - SCHEDULER_REQUEST& sreq, WORK_REQ& wreq, WORKUNIT& workunit, APP& + WORKUNIT& workunit, APP& ); extern bool hr_unknown_platform(HOST&); diff --git a/sched/sched_locality.cpp b/sched/sched_locality.cpp index 58caf86f3b..cab23a528a 100644 --- a/sched/sched_locality.cpp +++ b/sched/sched_locality.cpp @@ -49,26 +49,26 @@ using namespace std; // returns zero if there is a file we can delete. // -int delete_file_from_host(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& sreply) { +int delete_file_from_host() { #ifdef EINSTEIN_AT_HOME // append the list of deletion candidates to the file list - int ndelete_candidates = (int)sreq.file_delete_candidates.size(); + int ndelete_candidates = (int)g_request->file_delete_candidates.size(); for (int j=0; jfile_delete_candidates[j]; + g_request->file_infos.push_back(fi); } - sreq.file_delete_candidates.clear(); + g_request->file_delete_candidates.clear(); #endif - int nfiles = (int)sreq.file_infos.size(); + int nfiles = (int)g_request->file_infos.size(); char buf[256]; if (!nfiles) { double maxdisk=max_allowable_disk(); log_messages.printf(MSG_CRITICAL, - "[HOST#%d]: no disk space but no files we can delete!\n", sreply.host.id + "[HOST#%d]: no disk space but no files we can delete!\n", g_reply->host.id ); if (maxdisk > 0) { @@ -83,16 +83,16 @@ int delete_file_from_host(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& sreply) { ); } - if (sreply.disk_limits.max_used != 0.0) { + if (g_reply->disk_limits.max_used != 0.0) { strcat(buf, "Review preferences for maximum disk space used."); - } else if (sreply.disk_limits.max_frac != 0.0) { + } else if (g_reply->disk_limits.max_frac != 0.0) { strcat(buf, "Review preferences for maximum disk percentage used."); - } else if (sreply.disk_limits.min_free != 0.0) { + } else if (g_reply->disk_limits.min_free != 0.0) { strcat(buf, "Review preferences for minimum disk free space allowed."); } USER_MESSAGE um(buf, "high"); - sreply.insert_message(um); - sreply.set_delay(DELAY_DISK_SPACE); + g_reply->insert_message(um); + g_reply->set_delay(DELAY_DISK_SPACE); return 1; } @@ -106,11 +106,11 @@ int delete_file_from_host(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& sreply) { // the order in which it reports files is fixed. // If this is false, we need to sort files into order by name! // - int j = sreply.host.id % nfiles; - FILE_INFO& fi = sreq.file_infos[j]; - sreply.file_deletes.push_back(fi); + int j = g_reply->host.id % nfiles; + FILE_INFO& fi = g_request->file_infos[j]; + g_reply->file_deletes.push_back(fi); log_messages.printf(MSG_DEBUG, - "[HOST#%d]: delete file %s (make space)\n", sreply.host.id, fi.name + "[HOST#%d]: delete file %s (make space)\n", g_reply->host.id, fi.name ); // give host 4 hours to nuke the file and come back. @@ -119,28 +119,23 @@ int delete_file_from_host(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& sreply) { // sprintf(buf, "BOINC will delete file %s when no longer needed", fi.name); USER_MESSAGE um(buf, "low"); - sreply.insert_message(um); - sreply.set_delay(DELAY_DELETE_FILE); + g_reply->insert_message(um); + g_reply->set_delay(DELAY_DELETE_FILE); return 0; } // returns true if the host already has the file, or if the file is // included with a previous result being sent to this host. // -bool host_has_file( - SCHEDULER_REQUEST& request, - SCHEDULER_REPLY& reply, - char *filename, - bool skip_last_wu -) { +bool host_has_file(char *filename, bool skip_last_wu) { int i, uplim; bool has_file=false; // loop over files already on host to see if host already has the // file // - for (i=0; i<(int)request.file_infos.size(); i++) { - FILE_INFO& fi = request.file_infos[i]; + for (i=0; i<(int)g_request->file_infos.size(); i++) { + FILE_INFO& fi = g_request->file_infos[i]; if (!strcmp(filename, fi.name)) { has_file=true; break; @@ -149,7 +144,7 @@ bool host_has_file( if (has_file) { log_messages.printf(MSG_DEBUG, - "[HOST#%d] Already has file %s\n", reply.host.id, filename + "[HOST#%d] Already has file %s\n", g_reply->host.id, filename ); return true; } @@ -157,7 +152,7 @@ bool host_has_file( // loop over files being sent to host to see if this file has // already been counted. // - uplim=(int)reply.wus.size(); + uplim=(int)g_reply->wus.size(); if (skip_last_wu) { uplim--; } @@ -165,7 +160,7 @@ bool host_has_file( for (i=0; iwus[i].name, wu_filename)) { // work unit does not appear to contain a file name continue; } @@ -179,7 +174,7 @@ bool host_has_file( if (has_file) { log_messages.printf(MSG_DEBUG, - "[HOST#%d] file %s already in scheduler reply(%d)\n", reply.host.id, filename, i + "[HOST#%d] file %s already in scheduler reply(%d)\n", g_reply->host.id, filename, i ); return true; } @@ -200,10 +195,7 @@ bool host_has_file( // space in the work request should be adjusted by the calling // routine, in the same way as if there was no scheduling locality. // -int decrement_disk_space_locality( - WORKUNIT& wu, SCHEDULER_REQUEST& request, - SCHEDULER_REPLY& reply -) { +int decrement_disk_space_locality( WORKUNIT& wu) { char filename[256], path[512]; int filesize; struct stat buf; @@ -223,7 +215,7 @@ int decrement_disk_space_locality( // corresponds to the one that we are (possibly) going to send! // So make a copy and pop the current WU off the end. - if (!host_has_file(request, reply, filename, true)) + if (!host_has_file(filename, true)) return 1; // If we are here, then the host ALREADY has the file, or its size @@ -245,10 +237,10 @@ int decrement_disk_space_locality( filesize=buf.st_size; if (filesizedisk_available -= (wu.rsc_disk_bound-filesize); log_messages.printf(MSG_DEBUG, "[HOST#%d] reducing disk needed for WU by %d bytes (length of %s)\n", - reply.host.id, filesize, filename + g_reply->host.id, filesize, filename ); return 0; } @@ -266,10 +258,7 @@ int decrement_disk_space_locality( // - already sent a result for this WU // - no app_version available // -static int possibly_send_result( - DB_RESULT& result, - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { +static int possibly_send_result(DB_RESULT& result) { DB_WORKUNIT wu; DB_RESULT result2; int retval, count; @@ -281,15 +270,15 @@ static int possibly_send_result( bavp = get_app_version(wu); - if (!bavp && anonymous(sreq.platforms.list[0])) { + if (!bavp && anonymous(g_request->platforms.list[0])) { char help_msg_buf[512]; sprintf(help_msg_buf, "To get more %s work, finish current work, stop BOINC, remove app_info.xml file, and restart.", config.long_name ); USER_MESSAGE um(help_msg_buf, "high"); - reply.insert_message(um); - reply.set_delay(DELAY_ANONYMOUS); + g_reply->insert_message(um); + g_reply->set_delay(DELAY_ANONYMOUS); } if (!bavp) return ERR_NO_APP_VERSION; @@ -300,7 +289,7 @@ static int possibly_send_result( } if (config.one_result_per_user_per_wu) { - sprintf(buf, "where userid=%d and workunitid=%d", reply.user.id, wu.id); + sprintf(buf, "where userid=%d and workunitid=%d", g_reply->user.id, wu.id); retval = result2.count(count, buf); if (retval) return ERR_DB_NOT_FOUND; if (count > 0) return ERR_WU_USER_RULE; @@ -479,7 +468,6 @@ static void flag_for_possible_removal(char* filename) { static int send_results_for_file( char* filename, int& nsent, - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, bool /*in_working_set*/ ) { DB_RESULT result, prev_result; @@ -488,7 +476,7 @@ static int send_results_for_file( nsent = 0; - if (!work_needed(sreq, reply, true)) { + if (!work_needed(true)) { return 0; } @@ -501,11 +489,11 @@ static int send_results_for_file( sprintf(pattern, "%s__", filename); escape_mysql_like_pattern(pattern, escaped_pattern); sprintf(buf, "where userid=%d and name like binary '%s%%'", - reply.user.id, escaped_pattern + g_reply->user.id, escaped_pattern ); #else sprintf(buf, "where userid=%d and name>binary '%s__' and nameuser.id, filename, filename ); #endif retval_max = result.max_id(maxid, buf); @@ -519,7 +507,7 @@ static int send_results_for_file( for (i=0; i<100; i++) { // avoid infinite loop int query_retval; - if (!work_needed(sreq, reply, true)) break; + if (!work_needed(true)) break; log_messages.printf(MSG_DEBUG, "in_send_results_for_file(%s, %d) prev_result.id=%d\n", filename, i, prev_result.id @@ -633,7 +621,7 @@ static int send_results_for_file( // we found an unsent result, so try sending it. // This *should* always work. // - retval_send = possibly_send_result(result, sreq, reply); + retval_send = possibly_send_result(result); boinc_db.commit_transaction(); // if no app version or not enough resources, give up completely @@ -696,7 +684,6 @@ static int send_results_for_file( // min_resultname = R.filename; // static int send_new_file_work_deterministic_seeded( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, int& nsent, const char *start_f, const char *end_f ) { DB_RESULT result; @@ -736,11 +723,11 @@ static int send_new_file_work_deterministic_seeded( "send_new_file_work_deterministic will try filename %s\n", filename ); - retval = send_results_for_file(filename, nsent, sreq, reply, false); + retval = send_results_for_file(filename, nsent, false); if (retval==ERR_NO_APP_VERSION || retval==ERR_INSUFFICIENT_RESOURCE) return retval; - if (nsent>0 || !work_needed(sreq, reply, true)) break; + if (nsent>0 || !work_needed(true)) break; // construct a name which is lexically greater than the name of any result // which uses this file. sprintf(min_resultname, "%s__~", filename); @@ -749,14 +736,14 @@ static int send_new_file_work_deterministic_seeded( } -static bool is_host_slow(SCHEDULER_REQUEST& sreq) { +static bool is_host_slow() { // 0.0013 defines about the slowest 20% of E@H hosts. // should make this a config parameter in the future, // if this idea works. // static int speed_not_printed = 1; - double hostspeed = sreq.host.claimed_credit_per_cpu_sec; + double hostspeed = g_request->host.claimed_credit_per_cpu_sec; if (speed_not_printed) { speed_not_printed = 0; @@ -771,31 +758,29 @@ static bool is_host_slow(SCHEDULER_REQUEST& sreq) { // Returns 0 if this has sent additional new work. Returns non-zero // if it has not sent any new work. // -static int send_new_file_work_deterministic( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { +static int send_new_file_work_deterministic() { char start_filename[256]; int getfile_retval, nsent=0; // get random filename as starting point for deterministic search // If at this point, we have probably failed to find a suitable file // for a slow host, so ignore speed of host. - if ((getfile_retval = get_working_set_filename(start_filename, /* is_host_slow(sreq) */ false))) { + if ((getfile_retval = get_working_set_filename(start_filename, /* is_host_slow() */ false))) { strcpy(start_filename, ""); } // start deterministic search with randomly chosen filename, go to // lexical maximum - send_new_file_work_deterministic_seeded(sreq, reply, nsent, start_filename, NULL); + send_new_file_work_deterministic_seeded(nsent, start_filename, NULL); if (nsent) { return 0; } // continue deterministic search at lexically first possible // filename, continue to randomly choosen one - if (!getfile_retval && work_needed(sreq, reply, true)) { + if (!getfile_retval && work_needed(true)) { send_new_file_work_deterministic_seeded( - sreq, reply, nsent, "", start_filename + nsent, "", start_filename ); if (nsent) { return 0; @@ -806,35 +791,29 @@ static int send_new_file_work_deterministic( } -static int send_new_file_work_working_set( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { +static int send_new_file_work_working_set() { char filename[256]; int retval, nsent; - retval = get_working_set_filename(filename, is_host_slow(sreq)); + retval = get_working_set_filename(filename, is_host_slow()); if (retval) return retval; log_messages.printf(MSG_DEBUG, "send_new_file_working_set will try filename %s\n", filename ); - return send_results_for_file(filename, nsent, sreq, reply, true); + return send_results_for_file(filename, nsent, true); } // prototype -static int send_old_work( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, int t_min, int t_max -); +static int send_old_work(int t_min, int t_max); // The host doesn't have any files for which work is available. // Pick new file to send. Returns nonzero if no work is available. // -static int send_new_file_work( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { +static int send_new_file_work() { - while (work_needed(sreq, reply, true)) { + while (work_needed(true)) { int retval_sow, retval_snfwws; double frac=((double)rand())/(double)RAND_MAX; int now = time(0); @@ -852,33 +831,33 @@ static int send_new_file_work( "send_new_file_work(): try to send old work\n" ); - retval_sow=send_old_work(sreq, reply, start, end); + retval_sow=send_old_work(start, end); if (retval_sow==ERR_NO_APP_VERSION || retval_sow==ERR_INSUFFICIENT_RESOURCE) return retval_sow; - while (work_needed(sreq, reply, true) && retry<5) { + while (work_needed(true) && retry<5) { log_messages.printf(MSG_DEBUG, "send_new_file_work(%d): try to send from working set\n", retry ); retry++; - retval_snfwws=send_new_file_work_working_set(sreq, reply); + retval_snfwws=send_new_file_work_working_set(); if (retval_snfwws==ERR_NO_APP_VERSION || retval_snfwws==ERR_INSUFFICIENT_RESOURCE) return retval_snfwws; } - if (work_needed(sreq, reply, true)) { + if (work_needed(true)) { log_messages.printf(MSG_DEBUG, "send_new_file_work(): try deterministic method\n" ); - if (send_new_file_work_deterministic(sreq, reply)) { + if (send_new_file_work_deterministic()) { // if no work remains at all, // we learn it here and return nonzero. // return 1; } } - } // while reply.work_needed(sreq, reply, true) + } // while g_reply->work_needed(true) return 0; } @@ -890,15 +869,13 @@ static int send_new_file_work( // This looks for work created in the range t_min < t < t_max. Use // t_min=INT_MIN if you wish to leave off the left constraint. // -static int send_old_work( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, int t_min, int t_max -) { +static int send_old_work(int t_min, int t_max) { char buf[1024], filename[256]; int retval, extract_retval, nsent; DB_RESULT result; int now=time(0); - if (!work_needed(sreq, reply, true)) { + if (!work_needed(true)) { return 0; } @@ -918,7 +895,7 @@ static int send_old_work( retval = result.lookup(buf); if (!retval) { - retval = possibly_send_result(result, sreq, reply); + retval = possibly_send_result(result); boinc_db.commit_transaction(); if (!retval) { double age=(now-result.create_time)/3600.0; @@ -927,7 +904,7 @@ static int send_old_work( ); extract_retval=extract_filename(result.name, filename); if (!extract_retval) { - send_results_for_file(filename, nsent, sreq, reply, false); + send_results_for_file(filename, nsent, false); } else { // David, is this right? Is this the only place in // the locality scheduler that non-locality work // @@ -973,9 +950,7 @@ bool file_info_order(const FILE_INFO& fi1, const FILE_INFO& fi2) { return false; } -void send_work_locality( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply -) { +void send_work_locality() { int i, nsent, nfiles, j; // seed the random number generator @@ -983,9 +958,9 @@ void send_work_locality( srand(seed); #ifdef EINSTEIN_AT_HOME - std::vector eah_copy = sreq.file_infos; - sreq.file_infos.clear(); - sreq.files_not_needed.clear(); + std::vector eah_copy = g_request->file_infos; + g_request->file_infos.clear(); + g_request->files_not_needed.clear(); nfiles = (int) eah_copy.size(); for (i=0; ifiles_not_needed.push_back(eah_copy[i]); log_messages.printf(MSG_DEBUG, - "[HOST#%d] adding file %s to files_not_needed list\n", reply.host.id, fname + "[HOST#%d] adding file %s to files_not_needed list\n", g_reply->host.id, fname ); } else if (!data_files) { // these files MIGHT be deleted from host if we need to make // disk space there // - sreq.file_delete_candidates.push_back(eah_copy[i]); + g_request->file_delete_candidates.push_back(eah_copy[i]); log_messages.printf(MSG_DEBUG, - "[HOST#%d] removing file %s from file_infos list\n", reply.host.id, fname + "[HOST#%d] removing file %s from file_infos list\n", g_reply->host.id, fname ); } else { // these are files that we will use for locality scheduling and // to search for work // - sreq.file_infos.push_back(eah_copy[i]); + g_request->file_infos.push_back(eah_copy[i]); } } #endif // EINSTEIN_AT_HOME - nfiles = (int) sreq.file_infos.size(); + nfiles = (int) g_request->file_infos.size(); for (i=0; ihost.id, g_request->file_infos[i].name ); // Look for work in order of increasing file name, or randomly? // if (config.locality_scheduling_sorted_order) { - sort(sreq.file_infos.begin(), sreq.file_infos.end(), file_info_order); + sort(g_request->file_infos.begin(), g_request->file_infos.end(), file_info_order); j = 0; } else { if (!nfiles) nfiles = 1; @@ -1055,22 +1030,22 @@ void send_work_locality( // high-bandwidth connections, since asking dial-up users to upload // (presumably large) data files is onerous. // - if (config.locality_scheduling_send_timeout && sreq.host.n_bwdown>100000) { + if (config.locality_scheduling_send_timeout && g_request->host.n_bwdown>100000) { int until=time(0)-config.locality_scheduling_send_timeout; - int retval_sow=send_old_work(sreq, reply, INT_MIN, until); + int retval_sow=send_old_work(INT_MIN, until); if (retval_sow==ERR_NO_APP_VERSION || retval_sow==ERR_INSUFFICIENT_RESOURCE) return; } // send work for existing files // - for (i=0; i<(int)sreq.file_infos.size(); i++) { + for (i=0; i<(int)g_request->file_infos.size(); i++) { int k = (i+j)%nfiles; int retval_srff; - if (!work_needed(sreq, reply, true)) break; - FILE_INFO& fi = sreq.file_infos[k]; + if (!work_needed(true)) break; + FILE_INFO& fi = g_request->file_infos[k]; retval_srff=send_results_for_file( - fi.name, nsent, sreq, reply, false + fi.name, nsent, false ); if (retval_srff==ERR_NO_APP_VERSION || retval_srff==ERR_INSUFFICIENT_RESOURCE) return; @@ -1081,10 +1056,10 @@ void send_work_locality( // If the work was not sent for other (dynamic) reason such as insufficient // cpu, then DON'T delete the file. // - if (nsent == 0 && work_needed(sreq, reply, true) && config.file_deletion_strategy == 1) { - reply.file_deletes.push_back(fi); + if (nsent == 0 && work_needed(true) && config.file_deletion_strategy == 1) { + g_reply->file_deletes.push_back(fi); log_messages.printf(MSG_DEBUG, - "[HOST#%d]: delete file %s (not needed)\n", reply.host.id, fi.name + "[HOST#%d]: delete file %s (not needed)\n", g_reply->host.id, fi.name ); #ifdef EINSTEIN_AT_HOME // For name matching pattern h1_XXXX.XX_S5R2 @@ -1093,9 +1068,9 @@ void send_work_locality( if (strlen(fi.name)==15 && !strncmp("h1_", fi.name, 3)) { FILE_INFO fi_l = fi; fi_l.name[0]='l'; - reply.file_deletes.push_back(fi_l); + g_reply->file_deletes.push_back(fi_l); log_messages.printf(MSG_DEBUG, - "[HOST#%d]: delete file %s (not needed)\n", reply.host.id, fi_l.name + "[HOST#%d]: delete file %s (not needed)\n", g_reply->host.id, fi_l.name ); } #endif @@ -1104,42 +1079,42 @@ void send_work_locality( // send new files if needed // - if (work_needed(sreq, reply, true)) { - send_new_file_work(sreq, reply); + if (work_needed(true)) { + send_new_file_work(); } } // send instructions to delete useless files // -void send_file_deletes(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& sreply) { - int num_useless = sreq.files_not_needed.size(); +void send_file_deletes() { + int num_useless = g_request->files_not_needed.size(); int i; for (i=0; ifiles_not_needed[i]; + g_reply->file_deletes.push_back(fi); log_messages.printf(MSG_DEBUG, - "[HOST#%d]: delete file %s (not needed)\n", sreply.host.id, fi.name + "[HOST#%d]: delete file %s (not needed)\n", g_reply->host.id, fi.name ); sprintf(buf, "BOINC will delete file %s (no longer needed)", fi.name); USER_MESSAGE um(buf, "low"); - sreply.insert_message(um); + g_reply->insert_message(um); } // if we got no work, and we have no file space, delete some files // - if (sreply.results.size()==0 && (sreply.wreq.disk.insufficient || sreply.wreq.disk_available<0)) { + if (g_reply->results.size()==0 && (g_reply->wreq.disk.insufficient || g_reply->wreq.disk_available<0)) { // try to delete a file to make more space. // Also give some hints to the user about what's going wrong // (lack of disk space). // - delete_file_from_host(sreq, sreply); + delete_file_from_host(); } - if (sreply.results.size()==0 && sreply.hostid && sreq.work_req_seconds>1.0) { - debug_sched(sreq, sreply, "../debug_sched"); - } else if (max_allowable_disk()<0 || (sreply.wreq.disk.insufficient || sreply.wreq.disk_available<0)) { - debug_sched(sreq, sreply, "../debug_sched"); + if (g_reply->results.size()==0 && g_reply->hostid && g_request->work_req_seconds>1.0) { + debug_sched("../debug_sched"); + } else if (max_allowable_disk()<0 || (g_reply->wreq.disk.insufficient || g_reply->wreq.disk_available<0)) { + debug_sched("../debug_sched"); } } diff --git a/sched/sched_locality.h b/sched/sched_locality.h index 8924acc396..8a4b9d9196 100644 --- a/sched/sched_locality.h +++ b/sched/sched_locality.h @@ -15,12 +15,10 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -extern void send_work_locality(SCHEDULER_REQUEST&, SCHEDULER_REPLY&); +extern void send_work_locality(); -extern int decrement_disk_space_locality( - WORKUNIT& wu, SCHEDULER_REQUEST& request, SCHEDULER_REPLY& reply -); +extern int decrement_disk_space_locality(WORKUNIT& wu); -extern int delete_file_from_host(SCHEDULER_REQUEST&, SCHEDULER_REPLY&); +extern int delete_file_from_host(); -extern void send_file_deletes(SCHEDULER_REQUEST&, SCHEDULER_REPLY&); +extern void send_file_deletes(); diff --git a/sched/sched_resend.cpp b/sched/sched_resend.cpp index e9a02f4fad..51ab048339 100644 --- a/sched/sched_resend.cpp +++ b/sched/sched_resend.cpp @@ -96,7 +96,7 @@ static int possibly_give_result_new_deadline( // 3) aren't present on the host // Return true if there were any such jobs // -bool resend_lost_work(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +bool resend_lost_work() { DB_RESULT result; std::vectorresults; unsigned int i; @@ -109,12 +109,12 @@ bool resend_lost_work(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { int retval; sprintf(buf, " where hostid=%d and server_state=%d ", - reply.host.id, RESULT_SERVER_STATE_IN_PROGRESS + g_reply->host.id, RESULT_SERVER_STATE_IN_PROGRESS ); while (!result.enumerate(buf)) { bool found = false; - for (i=0; iother_results.size(); i++) { + OTHER_RESULT& orp = g_request->other_results[i]; if (!strcmp(orp.name.c_str(), result.name)) { found = true; break; @@ -126,7 +126,7 @@ bool resend_lost_work(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (config.debug_resend) { log_messages.printf(MSG_DEBUG, "[HOST#%d] found lost [RESULT#%d]: %s\n", - reply.host.id, result.id, result.name + g_reply->host.id, result.id, result.name ); } @@ -135,7 +135,7 @@ bool resend_lost_work(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (retval) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] WU not found for [RESULT#%d]\n", - reply.host.id, result.id + g_reply->host.id, result.id ); continue; } @@ -144,7 +144,7 @@ bool resend_lost_work(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (!bavp) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] no app version [RESULT#%d]\n", - reply.host.id, result.id + g_reply->host.id, result.id ); continue; } @@ -164,7 +164,7 @@ bool resend_lost_work(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (config.debug_resend) { log_messages.printf(MSG_DEBUG, "[HOST#%d][RESULT#%d] not needed or too close to deadline, expiring\n", - reply.host.id, result.id + g_reply->host.id, result.id ); } result.report_deadline = time(0)-1; @@ -187,19 +187,19 @@ bool resend_lost_work(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { "Didn't resend lost result %s (expired)", result.name ); USER_MESSAGE um(warning_msg, "high"); - reply.insert_message(um); + g_reply->insert_message(um); } else { retval = add_result_to_reply(result, wu, bavp); if (retval) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] failed to send [RESULT#%d]\n", - reply.host.id, result.id + g_reply->host.id, result.id ); continue; } sprintf(warning_msg, "Resent lost result %s", result.name); USER_MESSAGE um(warning_msg, "high"); - reply.insert_message(um); + g_reply->insert_message(um); num_resent++; did_any = true; } @@ -207,7 +207,7 @@ bool resend_lost_work(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (num_eligible_to_resend && config.debug_resend) { log_messages.printf(MSG_DEBUG, - "[HOST#%d] %d lost results, resent %d\n", reply.host.id, num_eligible_to_resend, num_resent + "[HOST#%d] %d lost results, resent %d\n", g_reply->host.id, num_eligible_to_resend, num_resent ); } diff --git a/sched/sched_resend.h b/sched/sched_resend.h index d7807b62fa..fe4ba00377 100644 --- a/sched/sched_resend.h +++ b/sched/sched_resend.h @@ -15,4 +15,4 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -extern bool resend_lost_work(SCHEDULER_REQUEST&, SCHEDULER_REPLY&); +extern bool resend_lost_work(); diff --git a/sched/sched_result.cpp b/sched/sched_result.cpp index c3bb055479..080e81e92b 100644 --- a/sched/sched_result.cpp +++ b/sched/sched_result.cpp @@ -28,7 +28,7 @@ // handle completed results // -int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { +int handle_results() { DB_SCHED_RESULT_ITEM_SET result_handler; SCHED_RESULT_ITEM* srip; unsigned int i; @@ -36,13 +36,13 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { RESULT* rp; bool changed_host=false; - if (sreq.results.size() == 0) return 0; + if (g_request->results.size() == 0) return 0; // copy reported results to a separate vector, "result_handler", // initially with only the "name" field present // - for (i=0; iresults.size(); i++) { + result_handler.add_result(g_request->results[i].name); } // read results from database into "result_handler". @@ -59,7 +59,7 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (retval) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] Batch query failed\n", - reply.host.id + g_reply->host.id ); } @@ -71,24 +71,24 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // In other words, the only time we don't ack a result is when // it looks OK but the update failed. // - for (i=0; iresults.size(); i++) { + rp = &g_request->results[i]; retval = result_handler.lookup_result(rp->name, &srip); if (retval) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] [RESULT#? %s] can't find result\n", - reply.host.id, rp->name + g_reply->host.id, rp->name ); - reply.result_acks.push_back(std::string(rp->name)); + g_reply->result_acks.push_back(std::string(rp->name)); continue; } if (config.debug_handle_results) { log_messages.printf(MSG_DEBUG, "[HOST#%d] [RESULT#%d %s] got result (DB: server_state=%d outcome=%d client_state=%d validate_state=%d delete_state=%d)\n", - reply.host.id, srip->id, srip->name, srip->server_state, + g_reply->host.id, srip->id, srip->name, srip->server_state, srip->outcome, srip->client_state, srip->validate_state, srip->file_delete_state ); @@ -143,14 +143,14 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { char buf[256]; log_messages.printf(MSG_CRITICAL, "[HOST#%d] [RESULT#%d %s] result already over [outcome=%d validate_state=%d]: %s\n", - reply.host.id, srip->id, srip->name, srip->outcome, + g_reply->host.id, srip->id, srip->name, srip->outcome, srip->validate_state, dont_replace_result ); sprintf(buf, "Completed result %s refused: %s", srip->name, dont_replace_result); USER_MESSAGE um(buf, "high"); - reply.insert_message(um); + g_reply->insert_message(um); srip->id = 0; - reply.result_acks.push_back(std::string(rp->name)); + g_reply->result_acks.push_back(std::string(rp->name)); continue; } } @@ -158,28 +158,28 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (srip->server_state == RESULT_SERVER_STATE_UNSENT) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] [RESULT#%d %s] got unexpected result: server state is %d\n", - reply.host.id, srip->id, srip->name, srip->server_state + g_reply->host.id, srip->id, srip->name, srip->server_state ); srip->id = 0; - reply.result_acks.push_back(std::string(rp->name)); + g_reply->result_acks.push_back(std::string(rp->name)); continue; } if (srip->received_time) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] [RESULT#%d %s] already got result, at %s \n", - reply.host.id, srip->id, srip->name, + g_reply->host.id, srip->id, srip->name, time_to_string(srip->received_time) ); srip->id = 0; - reply.result_acks.push_back(std::string(rp->name)); + g_reply->result_acks.push_back(std::string(rp->name)); continue; } - if (srip->hostid != reply.host.id) { + if (srip->hostid != g_reply->host.id) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] [RESULT#%d %s] got result from wrong host; expected [HOST#%d]\n", - reply.host.id, srip->id, srip->name, srip->hostid + g_reply->host.id, srip->id, srip->name, srip->hostid ); DB_HOST result_host; retval = result_host.lookup_id(srip->hostid); @@ -190,20 +190,20 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { srip->id, srip->name, srip->hostid ); srip->id = 0; - reply.result_acks.push_back(std::string(rp->name)); + g_reply->result_acks.push_back(std::string(rp->name)); continue; - } else if (result_host.userid != reply.host.userid) { + } else if (result_host.userid != g_reply->host.userid) { log_messages.printf(MSG_CRITICAL, "[USER#%d] [HOST#%d] [RESULT#%d %s] Not even the same user; expected [USER#%d]\n", - reply.host.userid, reply.host.id, srip->id, srip->name, result_host.userid + g_reply->host.userid, g_reply->host.id, srip->id, srip->name, result_host.userid ); srip->id = 0; - reply.result_acks.push_back(std::string(rp->name)); + g_reply->result_acks.push_back(std::string(rp->name)); continue; } else { log_messages.printf(MSG_CRITICAL, "[HOST#%d] [RESULT#%d %s] Allowing result because same USER#%d\n", - reply.host.id, srip->id, srip->name, reply.host.userid + g_reply->host.id, srip->id, srip->name, g_reply->host.userid ); changed_host = true; } @@ -213,8 +213,8 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // If we found a problem above, // we have continued and skipped this modify // - srip->hostid = reply.host.id; - srip->teamid = reply.user.teamid; + srip->hostid = g_reply->host.id; + srip->teamid = g_reply->user.teamid; srip->received_time = time(0); srip->client_state = rp->client_state; srip->cpu_time = rp->cpu_time; @@ -246,7 +246,7 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { rp->intops_per_cpu_sec*srip->cpu_time ); } else { - srip->claimed_credit = srip->cpu_time * reply.host.claimed_credit_per_cpu_sec; + srip->claimed_credit = srip->cpu_time * g_reply->host.claimed_credit_per_cpu_sec; } if (config.use_credit_multiplier) { @@ -259,7 +259,7 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (config.debug_handle_results) { log_messages.printf(MSG_DEBUG, - "cpu time %f credit/sec %f, claimed credit %f\n", srip->cpu_time, reply.host.claimed_credit_per_cpu_sec, srip->claimed_credit + "cpu time %f credit/sec %f, claimed credit %f\n", srip->cpu_time, g_reply->host.claimed_credit_per_cpu_sec, srip->claimed_credit ); } srip->server_state = RESULT_SERVER_STATE_OVER; @@ -281,7 +281,7 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { srip->id, srip->name ); } - reply.got_good_result(); + g_reply->got_good_result(); } else { if (config.debug_handle_results) { log_messages.printf(MSG_DEBUG, @@ -291,7 +291,7 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { } srip->outcome = RESULT_OUTCOME_CLIENT_ERROR; srip->validate_state = VALIDATE_STATE_INVALID; - reply.got_bad_result(); + g_reply->got_bad_result(); } } // loop over all incoming results @@ -305,10 +305,10 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (retval) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] [RESULT#%d %s] can't update result: %s\n", - reply.host.id, sri.id, sri.name, boinc_db.error_string() + g_reply->host.id, sri.id, sri.name, boinc_db.error_string() ); } else { - reply.result_acks.push_back(std::string(sri.name)); + g_reply->result_acks.push_back(std::string(sri.name)); } } @@ -318,7 +318,7 @@ int handle_results(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { if (retval) { log_messages.printf(MSG_CRITICAL, "[HOST#%d] can't update WUs: %d\n", - reply.host.id, retval + g_reply->host.id, retval ); } return 0; diff --git a/sched/sched_result.h b/sched/sched_result.h index 9af6276c9e..a322425d54 100644 --- a/sched/sched_result.h +++ b/sched/sched_result.h @@ -15,4 +15,4 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -extern int handle_results(SCHEDULER_REQUEST&, SCHEDULER_REPLY&); +extern int handle_results(); diff --git a/sched/sched_send.cpp b/sched/sched_send.cpp index 148c8ef9c9..0c82683536 100644 --- a/sched/sched_send.cpp +++ b/sched/sched_send.cpp @@ -633,7 +633,7 @@ int wu_is_infeasible_fast(WORKUNIT& wu, APP& app, BEST_APP_VERSION& bav) { } return INFEASIBLE_HR; } - if (already_sent_to_different_platform_quick(*g_request, wu, app)) { + if (already_sent_to_different_platform_quick(wu, app)) { if (config.debug_send) { log_messages.printf(MSG_DEBUG, "[HOST#%d] [WU#%d %s] failed quick HR check: WU is class %d, host is class %d\n", @@ -645,7 +645,7 @@ int wu_is_infeasible_fast(WORKUNIT& wu, APP& app, BEST_APP_VERSION& bav) { } if (config.one_result_per_user_per_wu || config.one_result_per_host_per_wu) { - if (wu_already_in_reply(wu, *g_reply)) { + if (wu_already_in_reply(wu)) { return INFEASIBLE_DUP; } } @@ -751,7 +751,7 @@ int add_wu_to_reply( APP_VERSION av2=*avp, *avp2=&av2; if (config.choose_download_url_by_timezone) { - process_av_timezone(reply, avp, av2); + process_av_timezone(avp, av2); } g_reply->insert_app_unique(*app); @@ -775,9 +775,9 @@ int add_wu_to_reply( log_messages.printf(MSG_CRITICAL, "insert_wu_tags failed %d\n", retval); return retval; } - wu3=wu2; + wu3 = wu2; if (config.choose_download_url_by_timezone) { - process_wu_timezone(reply, wu2, wu3); + process_wu_timezone(wu2, wu3); } g_reply->insert_workunit_unique(wu3); @@ -825,7 +825,7 @@ int update_wu_transition_time(WORKUNIT wu, time_t x) { // return true iff a result for same WU is already being sent // -bool wu_already_in_reply(WORKUNIT& wu, SCHEDULER_REPLY& reply) { +bool wu_already_in_reply(WORKUNIT& wu) { unsigned int i; for (i=0; iresults.size(); i++) { if (wu.id == g_reply->results[i].workunitid) { @@ -848,9 +848,7 @@ void unlock_sema() { // and we haven't exceeded result per RPC limit, // and we haven't exceeded results per day limit // -bool work_needed( - SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, bool locality_sched -) { +bool work_needed(bool locality_sched) { if (locality_sched) { // if we've failed to send a result because of a transient condition, // return false to preserve invariant @@ -922,7 +920,7 @@ int add_result_to_reply(DB_RESULT& result, WORKUNIT& wu, BEST_APP_VERSION* bavp) // IF the host already has the file OR the file was not already sent. // if (!config.locality_scheduling || - decrement_disk_space_locality(wu, *g_request, *g_reply) + decrement_disk_space_locality(wu) ) { g_wreq->disk_available -= wu.rsc_disk_bound; } @@ -1294,7 +1292,7 @@ static void send_work_old() { if (g_wreq->reliable) { g_wreq->reliable_only = true; g_wreq->infeasible_only = false; - scan_work_array(*g_request, *g_reply); + scan_work_array(); } g_wreq->reliable_only = false; @@ -1310,17 +1308,17 @@ static void send_work_old() { g_reply->host.id ); } - scan_work_array(*g_request, *g_reply); + scan_work_array(); } g_wreq->beta_only = false; // give next priority to results that were infeasible for some other host // g_wreq->infeasible_only = true; - scan_work_array(*g_request, *g_reply); + scan_work_array(); g_wreq->infeasible_only = false; - scan_work_array(*g_request, *g_reply); + scan_work_array(); // If user has selected apps but will accept any, // and we haven't found any jobs for selected apps, try others @@ -1334,7 +1332,7 @@ static void send_work_old() { g_reply->host.id ); } - scan_work_array(*g_request, *g_reply); + scan_work_array(); } } @@ -1406,7 +1404,7 @@ void send_work() { } if (config.enable_assignment) { - if (send_assigned_jobs(*g_request, *g_reply)) { + if (send_assigned_jobs()) { if (config.debug_assignment) { log_messages.printf(MSG_DEBUG, "[HOST#%d] sent assigned jobs\n", g_reply->host.id @@ -1424,7 +1422,7 @@ void send_work() { if (config.locality_scheduling) { g_wreq->infeasible_only = false; - send_work_locality(*g_request, *g_reply); + send_work_locality(); } else if (config.matchmaker) { send_work_matchmaker(); } else { @@ -1662,9 +1660,7 @@ bool wu_is_infeasible_slow( APP* app = ssp->lookup_app(wu_result.workunit.appid); WORKUNIT wu = wu_result.workunit; if (app_hr_type(*app)) { - if (already_sent_to_different_platform_careful( - sreq, *g_wreq, wu, *app - )) { + if (already_sent_to_different_platform_careful(wu, *app)) { if (config.debug_send) { log_messages.printf(MSG_DEBUG, "[HOST#%d] [WU#%d %s] WU is infeasible (assigned to different platform)\n", diff --git a/sched/sched_send.h b/sched/sched_send.h index de8aad8491..6c3ff685cf 100644 --- a/sched/sched_send.h +++ b/sched/sched_send.h @@ -47,7 +47,7 @@ extern int wu_is_infeasible_fast(WORKUNIT&, APP&, BEST_APP_VERSION&); extern double max_allowable_disk(); -extern bool wu_already_in_reply(WORKUNIT& wu, SCHEDULER_REPLY& reply); +extern bool wu_already_in_reply(WORKUNIT& wu); extern double estimate_duration(WORKUNIT& wu, BEST_APP_VERSION&); @@ -57,4 +57,4 @@ extern void lock_sema(); extern void unlock_sema(); extern const char* infeasible_string(int); extern bool app_not_selected(WORKUNIT&); -extern bool work_needed(SCHEDULER_REQUEST&, SCHEDULER_REPLY&, bool); +extern bool work_needed(bool); diff --git a/sched/sched_timezone.cpp b/sched/sched_timezone.cpp index 2294c67beb..bdf5012fea 100644 --- a/sched/sched_timezone.cpp +++ b/sched/sched_timezone.cpp @@ -242,7 +242,7 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) { // advance pointer to start looking for next tag. // - p=r; + p = r; } strcpy(new_xml, r); @@ -252,23 +252,21 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) { // replace the download URL for apps with a list of // multiple download servers. // -void process_av_timezone( - SCHEDULER_REPLY& reply, APP_VERSION* avp, APP_VERSION& av2 -) { +void process_av_timezone(APP_VERSION* avp, APP_VERSION& av2) { int retval; // set these global variables, needed by the compare() // function so that the download URL list can be sorted by timezone // - tzone=reply.host.timezone; - hostid=reply.host.id; - retval = add_download_servers(avp->xml_doc, av2.xml_doc, reply.host.timezone); + tzone = g_reply->host.timezone; + hostid = g_reply->host.id; + retval = add_download_servers(avp->xml_doc, av2.xml_doc, g_reply->host.timezone); if (retval) { log_messages.printf(MSG_CRITICAL, "add_download_servers(to APP version) failed\n" ); // restore original WU! - av2=*avp; + av2 = *avp; } } @@ -276,20 +274,20 @@ void process_av_timezone( // multiple download servers. // void process_wu_timezone( - SCHEDULER_REPLY& reply, WORKUNIT& wu2, WORKUNIT& wu3 + WORKUNIT& wu2, WORKUNIT& wu3 ) { int retval; - tzone=reply.host.timezone; - hostid=reply.host.id; + tzone = g_reply->host.timezone; + hostid = g_reply->host.id; - retval = add_download_servers(wu2.xml_doc, wu3.xml_doc, reply.host.timezone); + retval = add_download_servers(wu2.xml_doc, wu3.xml_doc, g_reply->host.timezone); if (retval) { log_messages.printf(MSG_CRITICAL, "add_download_servers(to WU) failed\n" ); // restore original WU! - wu3=wu2; + wu3 = wu2; } } diff --git a/sched/sched_timezone.h b/sched/sched_timezone.h index b0ffa2dee6..f74b39242c 100644 --- a/sched/sched_timezone.h +++ b/sched/sched_timezone.h @@ -15,10 +15,6 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -extern void process_av_timezone( - SCHEDULER_REPLY& reply, APP_VERSION* avp, APP_VERSION& av2 -); +extern void process_av_timezone(APP_VERSION* avp, APP_VERSION& av2); -extern void process_wu_timezone( - SCHEDULER_REPLY& reply, WORKUNIT& wu2, WORKUNIT& wu3 -); +extern void process_wu_timezone(WORKUNIT& wu2, WORKUNIT& wu3); diff --git a/sched/server_types.cpp b/sched/server_types.cpp index ac88df9eec..2466b81f2d 100644 --- a/sched/server_types.cpp +++ b/sched/server_types.cpp @@ -610,7 +610,7 @@ int SCHEDULER_REPLY::write(FILE* fout, SCHEDULER_REQUEST& sreq) { ); if (config.request_time_stats_log) { - if (!have_time_stats_log(*this)) { + if (!have_time_stats_log()) { fprintf(fout, "1\n"); } } diff --git a/sched/time_stats_log.cpp b/sched/time_stats_log.cpp index 698da3a9e5..160df6947e 100644 --- a/sched/time_stats_log.cpp +++ b/sched/time_stats_log.cpp @@ -39,10 +39,10 @@ void handle_time_stats_log(FILE* fin) { // The host has been authenticated, so write the stats. // Use a directory hierarchy since there may be many hosts // -void write_time_stats_log(SCHEDULER_REPLY& reply) { +void write_time_stats_log() { char dirname[256], filename[256]; - int hostid = reply.host.id; + int hostid = g_reply->host.id; int dirnum = hostid % 1000; sprintf(dirname, "../time_stats_log/%d", dirnum); if (!is_dir(dirname)) { @@ -73,10 +73,10 @@ void write_time_stats_log(SCHEDULER_REPLY& reply) { stats_buf = 0; } -bool have_time_stats_log(SCHEDULER_REPLY& reply) { +bool have_time_stats_log() { char filename[256]; - int hostid = reply.host.id; + int hostid = g_reply->host.id; int dirnum = hostid % 1000; sprintf(filename, "../time_stats_log/%d/%d", dirnum, hostid); return is_file(filename); diff --git a/sched/time_stats_log.h b/sched/time_stats_log.h index 012c217fbe..a611c14d13 100644 --- a/sched/time_stats_log.h +++ b/sched/time_stats_log.h @@ -19,5 +19,5 @@ #include "server_types.h" extern void handle_time_stats_log(FILE* fin); -extern void write_time_stats_log(SCHEDULER_REPLY& reply); -extern bool have_time_stats_log(SCHEDULER_REPLY& reply); +extern void write_time_stats_log(); +extern bool have_time_stats_log();