2004-11-20 07:32:32 +00:00
|
|
|
static volatile const char *BOINCrcsid="$Id$";
|
2003-07-01 20:37:09 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2002-04-30 22:22:54 +00:00
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
2003-07-01 20:37:09 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
2003-07-02 02:02:18 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
2003-07-02 20:57:59 +00:00
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-07-02 02:02:18 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2003-02-24 21:25:16 +00:00
|
|
|
// High-level logic for communicating with scheduling servers,
|
2002-07-15 05:34:32 +00:00
|
|
|
// and for merging the result of a scheduler RPC into the client state
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2004-01-30 22:19:19 +00:00
|
|
|
// The scheduler RPC mechanism is in scheduler_op.C
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2003-10-16 19:03:49 +00:00
|
|
|
#include "cpp.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2002-04-30 22:22:54 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <time.h>
|
2004-01-08 00:27:59 +00:00
|
|
|
#include <strings.h>
|
2004-01-10 06:40:46 +00:00
|
|
|
#endif
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-07-07 20:39:24 +00:00
|
|
|
#include "crypt.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "error_numbers.h"
|
|
|
|
#include "file_names.h"
|
2002-08-22 21:47:19 +00:00
|
|
|
#include "filesys.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "parse.h"
|
2003-02-24 21:25:16 +00:00
|
|
|
#include "util.h"
|
2003-02-21 01:38:16 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "scheduler_op.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#include "client_state.h"
|
|
|
|
|
2004-07-02 03:20:17 +00:00
|
|
|
using std::max;
|
2004-06-30 18:17:21 +00:00
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
static double trs;
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
// quantities like avg CPU time decay by a factor of e every week
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2003-02-24 21:25:16 +00:00
|
|
|
#define EXP_DECAY_RATE (1./(SECONDS_PER_DAY*7))
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2004-06-18 22:56:46 +00:00
|
|
|
// how often to show user "backing off" messages
|
|
|
|
//
|
2003-07-03 00:48:43 +00:00
|
|
|
const int SECONDS_BEFORE_REPORTING_MIN_RPC_TIME_AGAIN = 60*60;
|
|
|
|
|
2004-03-17 02:06:09 +00:00
|
|
|
|
2004-06-18 22:56:46 +00:00
|
|
|
// try to report results this much before their deadline
|
2004-05-05 21:15:34 +00:00
|
|
|
//
|
2004-06-18 22:56:46 +00:00
|
|
|
#define REPORT_DEADLINE_CUSHION SECONDS_PER_DAY
|
2003-08-07 23:08:15 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
static int proj_min_results(PROJECT* p, int ncpus) {
|
|
|
|
return (int)(ceil(ncpus*p->resource_share/trs));
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-10-25 20:16:30 +00:00
|
|
|
void PROJECT::set_min_rpc_time(double future_time) {
|
2004-02-10 07:11:18 +00:00
|
|
|
if (future_time > min_rpc_time) {
|
|
|
|
min_rpc_time = future_time;
|
|
|
|
}
|
2004-10-25 20:16:30 +00:00
|
|
|
min_report_min_rpc_time = 0;
|
2003-07-03 00:48:43 +00:00
|
|
|
}
|
|
|
|
|
2003-08-01 21:50:09 +00:00
|
|
|
// Return true iff we should not contact the project yet.
|
|
|
|
// Print a message to the user if we haven't recently
|
|
|
|
//
|
2004-10-25 20:16:30 +00:00
|
|
|
bool PROJECT::waiting_until_min_rpc_time(double now) {
|
2003-07-03 00:48:43 +00:00
|
|
|
if (min_rpc_time > now ) {
|
|
|
|
if (now >= min_report_min_rpc_time) {
|
|
|
|
min_report_min_rpc_time = now + SECONDS_BEFORE_REPORTING_MIN_RPC_TIME_AGAIN;
|
2003-08-01 21:50:09 +00:00
|
|
|
msg_printf(
|
|
|
|
this, MSG_ERROR,
|
|
|
|
"Deferring communication with project for %s\n",
|
|
|
|
timediff_format(min_rpc_time - now).c_str()
|
|
|
|
);
|
2003-07-03 00:48:43 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// find a project that needs its master file parsed
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
PROJECT* CLIENT_STATE::next_project_master_pending() {
|
|
|
|
unsigned int i;
|
|
|
|
PROJECT* p;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
p = projects[i];
|
2003-07-03 00:48:43 +00:00
|
|
|
if (p->waiting_until_min_rpc_time(now)) continue;
|
2002-07-15 05:34:32 +00:00
|
|
|
if (p->master_url_fetch_pending) {
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-02-13 23:02:45 +00:00
|
|
|
// find a project that needs to contact its scheduling server
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2003-02-13 23:02:45 +00:00
|
|
|
PROJECT* CLIENT_STATE::next_project_sched_rpc_pending() {
|
|
|
|
unsigned int i;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2003-02-13 23:02:45 +00:00
|
|
|
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
2003-07-03 00:48:43 +00:00
|
|
|
if (projects[i]->waiting_until_min_rpc_time(now)) continue;
|
2003-02-13 23:02:45 +00:00
|
|
|
if (projects[i]->sched_rpc_pending) {
|
|
|
|
return projects[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
// return the next project after "old" that
|
|
|
|
// 1) is eligible for a scheduler RPC
|
|
|
|
// 2) has work_request > 0
|
|
|
|
// 3) has master_url_fetch_pending == false
|
2004-06-30 01:10:22 +00:00
|
|
|
//
|
2004-09-22 22:09:54 +00:00
|
|
|
PROJECT* CLIENT_STATE::next_project_need_work(PROJECT *old) {
|
2004-06-30 01:10:22 +00:00
|
|
|
PROJECT *p;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2004-06-30 01:10:22 +00:00
|
|
|
unsigned int i;
|
2004-07-14 20:55:26 +00:00
|
|
|
bool found_old = (old == 0);
|
2004-06-30 01:10:22 +00:00
|
|
|
for (i=0; i<projects.size(); ++i) {
|
|
|
|
p = projects[i];
|
2004-07-24 01:25:10 +00:00
|
|
|
if (p == old) {
|
|
|
|
found_old = true;
|
|
|
|
continue;
|
|
|
|
}
|
2004-06-30 01:10:22 +00:00
|
|
|
if (p->master_url_fetch_pending) continue;
|
|
|
|
if (p->waiting_until_min_rpc_time(now)) continue;
|
|
|
|
if (found_old && p->work_request > 0) {
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
// Write a scheduler request to a disk file
|
|
|
|
// (later sent to the scheduling server)
|
2002-07-15 23:21:20 +00:00
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
|
2004-09-22 22:09:54 +00:00
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
get_sched_request_filename(*p, buf);
|
|
|
|
FILE* f = boinc_fopen(buf, "wb");
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE mf;
|
2002-04-30 22:22:54 +00:00
|
|
|
unsigned int i;
|
|
|
|
RESULT* rp;
|
2003-03-08 23:48:05 +00:00
|
|
|
int retval;
|
2004-08-11 15:50:51 +00:00
|
|
|
#if 0
|
|
|
|
double free, possible;
|
|
|
|
#endif
|
2004-04-18 18:40:13 +00:00
|
|
|
char cross_project_id[MD5_LEN];
|
2002-08-15 22:03:41 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
trs = total_resource_share();
|
2004-07-06 21:51:49 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
if (!f) return ERR_FOPEN;
|
2004-06-12 04:45:36 +00:00
|
|
|
mf.init_file(f);
|
2002-04-30 22:22:54 +00:00
|
|
|
fprintf(f,
|
|
|
|
"<scheduler_request>\n"
|
|
|
|
" <authenticator>%s</authenticator>\n"
|
|
|
|
" <hostid>%d</hostid>\n"
|
|
|
|
" <rpc_seqno>%d</rpc_seqno>\n"
|
|
|
|
" <platform_name>%s</platform_name>\n"
|
2002-12-01 06:14:28 +00:00
|
|
|
" <core_client_major_version>%d</core_client_major_version>\n"
|
|
|
|
" <core_client_minor_version>%d</core_client_minor_version>\n"
|
2004-07-06 23:27:19 +00:00
|
|
|
" <work_req_seconds>%f</work_req_seconds>\n"
|
2004-07-14 20:55:26 +00:00
|
|
|
" <resource_share_fraction>%f</resource_share_fraction>\n"
|
2004-10-01 08:15:58 +00:00
|
|
|
" <estimated_delay>%f</estimated_delay>\n",
|
2002-04-30 22:22:54 +00:00
|
|
|
p->authenticator,
|
|
|
|
p->hostid,
|
|
|
|
p->rpc_seqno,
|
2004-01-26 19:42:39 +00:00
|
|
|
p->anonymous_platform?"anonymous":platform_name,
|
2002-12-01 06:14:28 +00:00
|
|
|
core_client_major_version,
|
|
|
|
core_client_minor_version,
|
2004-07-06 21:51:49 +00:00
|
|
|
work_req,
|
2004-07-14 20:55:26 +00:00
|
|
|
p->resource_share / trs,
|
2004-10-01 08:15:58 +00:00
|
|
|
ettprc(p, proj_min_results(p, ncpus)-1)
|
2002-04-30 22:22:54 +00:00
|
|
|
);
|
2004-01-26 19:42:39 +00:00
|
|
|
if (p->anonymous_platform) {
|
|
|
|
fprintf(f, " <app_versions>\n");
|
|
|
|
for (i=0; i<app_versions.size(); i++) {
|
|
|
|
APP_VERSION* avp = app_versions[i];
|
|
|
|
if (avp->project != p) continue;
|
2004-06-12 04:45:36 +00:00
|
|
|
avp->write(mf);
|
2004-01-26 19:42:39 +00:00
|
|
|
}
|
|
|
|
fprintf(f, " </app_versions>\n");
|
|
|
|
}
|
2004-08-11 15:50:51 +00:00
|
|
|
#if 0
|
2004-08-06 21:54:40 +00:00
|
|
|
anything_free(free);
|
|
|
|
fprintf(f, " <project_disk_free>%f</project_disk_free>\n", free);
|
|
|
|
total_potential_offender(p, possible);
|
|
|
|
fprintf(f, " <potentially_free_offender>%f</potentially_free_offender>\n", possible);
|
|
|
|
total_potential_self(p, possible);
|
|
|
|
fprintf(f, " <potentially_free_self>%f</potentially_free_self>\n", possible);
|
2004-08-11 15:50:51 +00:00
|
|
|
#endif
|
2003-02-11 19:41:08 +00:00
|
|
|
if (strlen(p->code_sign_key)) {
|
2004-08-05 21:42:26 +00:00
|
|
|
fprintf(f, " <code_sign_key>\n%s</code_sign_key>\n", p->code_sign_key);
|
2002-07-07 20:39:24 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
// insert global preferences if present
|
|
|
|
//
|
2004-03-01 19:11:12 +00:00
|
|
|
if (boinc_file_exists(GLOBAL_PREFS_FILE_NAME)) {
|
|
|
|
FILE* fprefs = fopen(GLOBAL_PREFS_FILE_NAME, "r");
|
|
|
|
if (fprefs) {
|
|
|
|
copy_stream(fprefs, f);
|
|
|
|
fclose(fprefs);
|
|
|
|
}
|
2004-10-06 19:09:37 +00:00
|
|
|
PROJECT* pp = lookup_project(global_prefs.source_project);
|
2004-05-03 02:18:35 +00:00
|
|
|
if (pp && strlen(pp->email_hash)) {
|
|
|
|
fprintf(f,
|
|
|
|
"<global_prefs_source_email_hash>%s</global_prefs_source_email_hash>\n",
|
|
|
|
pp->email_hash
|
|
|
|
);
|
|
|
|
}
|
2002-09-29 00:32:11 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2004-04-18 18:40:13 +00:00
|
|
|
// send the maximum of cross_project_id over projects
|
|
|
|
// with the same email hash as this one
|
|
|
|
//
|
|
|
|
strcpy(cross_project_id, p->cross_project_id);
|
|
|
|
for (i=0; i<projects.size(); i++ ) {
|
|
|
|
PROJECT* project = projects[i];
|
|
|
|
if (project == p) continue;
|
|
|
|
if (strcmp(project->email_hash, p->email_hash)) continue;
|
|
|
|
if (strcmp(project->cross_project_id, cross_project_id) > 0) {
|
|
|
|
strcpy(cross_project_id, project->cross_project_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(f, "<cross_project_id>%s</cross_project_id>\n", cross_project_id);
|
|
|
|
|
2004-09-10 00:41:48 +00:00
|
|
|
#if 0
|
|
|
|
// no reason to report other projects.
|
|
|
|
//
|
2003-06-17 18:59:36 +00:00
|
|
|
fprintf(f, "<projects>\n");
|
|
|
|
for (i=0; i<projects.size(); i++ ) {
|
|
|
|
PROJECT* project = projects[i];
|
|
|
|
fprintf(f,
|
|
|
|
" <project>\n"
|
|
|
|
" <master_url>%s</master_url>\n"
|
|
|
|
" <resource_share>%f</resource_share>\n"
|
|
|
|
" </project>\n",
|
|
|
|
project->master_url,
|
|
|
|
project->resource_share
|
|
|
|
);
|
|
|
|
}
|
|
|
|
fprintf(f, "</projects>\n");
|
2004-09-10 00:41:48 +00:00
|
|
|
#endif
|
2003-06-17 18:59:36 +00:00
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
retval = time_stats.write(mf, true);
|
2003-03-08 23:48:05 +00:00
|
|
|
if (retval) return retval;
|
2004-09-22 21:08:26 +00:00
|
|
|
retval = net_stats.write(mf);
|
2003-03-08 23:48:05 +00:00
|
|
|
if (retval) return retval;
|
2004-06-12 04:45:36 +00:00
|
|
|
retval = host_info.write(mf);
|
2003-03-08 23:48:05 +00:00
|
|
|
if (retval) return retval;
|
2002-04-30 22:22:54 +00:00
|
|
|
for (i=0; i<results.size(); i++) {
|
2003-02-06 19:01:49 +00:00
|
|
|
rp = results[i];
|
2003-09-23 23:19:41 +00:00
|
|
|
if (rp->project == p && rp->ready_to_report) {
|
2004-06-12 04:45:36 +00:00
|
|
|
rp->write(mf, true);
|
2003-06-18 23:41:31 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-07-06 17:37:58 +00:00
|
|
|
|
2004-01-08 00:27:59 +00:00
|
|
|
read_trickle_files(p, f);
|
2004-09-10 00:41:48 +00:00
|
|
|
|
|
|
|
// report sticky files as needed
|
|
|
|
//
|
|
|
|
for (i=0; i<file_infos.size(); i++) {
|
|
|
|
FILE_INFO* fip = file_infos[i];
|
|
|
|
if (fip->project != p) continue;
|
|
|
|
if (!fip->report_on_rpc) continue;
|
|
|
|
fprintf(f,
|
|
|
|
" <file_info>\n"
|
|
|
|
" <name>%s</name>\n"
|
2004-09-10 21:02:11 +00:00
|
|
|
" <report_on_rpc/>\n"
|
2004-09-10 00:41:48 +00:00
|
|
|
" </file_info>\n",
|
|
|
|
fip->name
|
|
|
|
);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
fprintf(f, "</scheduler_request>\n");
|
2004-07-06 17:37:58 +00:00
|
|
|
|
2004-07-06 18:31:56 +00:00
|
|
|
fclose(f);
|
2002-04-30 22:22:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// find a project with results that are overdue to report,
|
|
|
|
// and which we're allowed to contact.
|
|
|
|
//
|
2004-06-18 22:56:46 +00:00
|
|
|
PROJECT* CLIENT_STATE::find_project_with_overdue_results() {
|
2002-07-15 05:34:32 +00:00
|
|
|
unsigned int i;
|
|
|
|
RESULT* r;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
for (i=0; i<results.size(); i++) {
|
2003-02-06 19:01:49 +00:00
|
|
|
r = results[i];
|
2003-08-07 23:08:15 +00:00
|
|
|
// return the project for this result to report if:
|
|
|
|
// - we're not backing off a scheduler request for its project
|
2003-09-23 23:19:41 +00:00
|
|
|
// - we're ready_to_report (compute done; files uploaded)
|
2004-06-18 22:56:46 +00:00
|
|
|
// - we're almost at the report_deadline
|
2003-09-23 23:19:41 +00:00
|
|
|
//
|
|
|
|
|
2003-07-03 00:48:43 +00:00
|
|
|
if (r->project->waiting_until_min_rpc_time(now)) continue;
|
2003-09-23 23:19:41 +00:00
|
|
|
|
2004-06-18 22:56:46 +00:00
|
|
|
if (!r->ready_to_report) continue;
|
2004-06-18 23:25:48 +00:00
|
|
|
if (return_results_immediately ||
|
|
|
|
(r->report_deadline <= (now + REPORT_DEADLINE_CUSHION))
|
|
|
|
) {
|
2003-02-06 19:01:49 +00:00
|
|
|
return r->project;
|
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2003-02-06 01:02:56 +00:00
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return true if we're allowed to do a scheduler RPC to at least one project
|
|
|
|
//
|
|
|
|
bool CLIENT_STATE::some_project_rpc_ok() {
|
|
|
|
unsigned int i;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
if (projects[i]->min_rpc_time < now) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// return the average number of CPU seconds completed by the client
|
|
|
|
// for project p in a second of (wall-clock) time
|
2004-06-30 01:10:22 +00:00
|
|
|
//
|
2004-07-14 20:55:26 +00:00
|
|
|
double CLIENT_STATE::avg_proc_rate(PROJECT *p) {
|
2004-10-14 22:01:05 +00:00
|
|
|
return (p->resource_share / trs) * ncpus * time_stats.active_frac;
|
2004-07-14 20:55:26 +00:00
|
|
|
}
|
2004-06-30 01:10:22 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// "estimated time to project result count"
|
|
|
|
// return the estimated amount of time that will elapse until the
|
|
|
|
// number of results for project p will reach k
|
|
|
|
//
|
|
|
|
double CLIENT_STATE::ettprc(PROJECT *p, int k) {
|
|
|
|
int num_results_to_skip = k;
|
|
|
|
double est = 0;
|
|
|
|
|
|
|
|
// total up the estimated time for this project's unstarted
|
|
|
|
// and partially completed results,
|
|
|
|
// omitting the last k
|
|
|
|
//
|
|
|
|
for (vector<RESULT*>::reverse_iterator iter = results.rbegin();
|
|
|
|
iter != results.rend(); iter++
|
|
|
|
) {
|
|
|
|
RESULT *rp = *iter;
|
|
|
|
if (rp->project != p
|
2004-10-07 19:18:37 +00:00
|
|
|
|| rp->state > RESULT_FILES_DOWNLOADED
|
2004-07-14 20:55:26 +00:00
|
|
|
|| rp->ready_to_report
|
|
|
|
) continue;
|
|
|
|
if (num_results_to_skip > 0) {
|
|
|
|
--num_results_to_skip;
|
|
|
|
continue;
|
|
|
|
}
|
2004-10-20 21:11:29 +00:00
|
|
|
est += rp->estimated_cpu_time_remaining();
|
2004-06-30 01:10:22 +00:00
|
|
|
}
|
2004-07-14 20:55:26 +00:00
|
|
|
est /= avg_proc_rate(p);
|
|
|
|
return est;
|
|
|
|
}
|
2004-06-30 01:10:22 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// set work_request for each project and return the urgency level for
|
|
|
|
// requesting more work
|
|
|
|
// only set non-zero work requests for projects that are allowed to do
|
|
|
|
// a scheduler RPC
|
|
|
|
//
|
|
|
|
int CLIENT_STATE::compute_work_requests() {
|
|
|
|
int urgency = DONT_NEED_WORK;
|
|
|
|
unsigned int i;
|
|
|
|
double work_min_period = global_prefs.work_buf_min_days * SECONDS_PER_DAY;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2004-07-14 20:55:26 +00:00
|
|
|
|
|
|
|
trs = total_resource_share();
|
|
|
|
|
|
|
|
// for each project, compute
|
|
|
|
// min_results = min # of results for project needed by CPU scheduling,
|
|
|
|
// to avoid "starvation".
|
|
|
|
// Then estimate how long it's going to be until we have fewer
|
|
|
|
// than this # of results remaining.
|
|
|
|
//
|
|
|
|
for (i=0; i<projects.size(); ++i) {
|
2004-06-30 01:10:22 +00:00
|
|
|
PROJECT *p = projects[i];
|
2004-07-14 20:55:26 +00:00
|
|
|
int min_results = proj_min_results(p, ncpus);
|
|
|
|
double estimated_time_to_starvation = ettprc(p, min_results-1);
|
|
|
|
|
2004-06-30 01:10:22 +00:00
|
|
|
p->work_request = 0;
|
2004-07-14 20:55:26 +00:00
|
|
|
if (p->min_rpc_time >= now) continue;
|
2004-06-30 01:10:22 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// determine urgency
|
|
|
|
//
|
|
|
|
if (estimated_time_to_starvation < work_min_period) {
|
|
|
|
if (estimated_time_to_starvation == 0) {
|
2004-10-14 22:21:35 +00:00
|
|
|
//msg_printf(p, MSG_INFO, "is starved");
|
2004-07-14 20:55:26 +00:00
|
|
|
urgency = NEED_WORK_IMMEDIATELY;
|
|
|
|
} else {
|
2004-10-14 22:21:35 +00:00
|
|
|
#if 0
|
2004-10-14 22:01:05 +00:00
|
|
|
msg_printf(p, MSG_INFO, "will starve in %.2f sec",
|
|
|
|
estimated_time_to_starvation
|
|
|
|
);
|
2004-10-14 22:21:35 +00:00
|
|
|
#endif
|
2004-07-14 20:55:26 +00:00
|
|
|
urgency = max(NEED_WORK, urgency);
|
2004-06-30 01:10:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// determine work requests for each project
|
2004-10-14 22:01:05 +00:00
|
|
|
// NOTE: don't need to divide by active_frac etc.;
|
|
|
|
// the scheduler does that (see sched/sched_send.C)
|
2004-07-14 20:55:26 +00:00
|
|
|
//
|
2004-10-14 22:01:05 +00:00
|
|
|
p->work_request = max(0.0,
|
|
|
|
//(2*work_min_period - estimated_time_to_starvation)
|
|
|
|
(work_min_period - estimated_time_to_starvation)
|
|
|
|
* ncpus
|
|
|
|
);
|
|
|
|
//msg_printf(p, MSG_INFO, "work req: %f sec", p->work_request);
|
2004-07-14 20:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (urgency == DONT_NEED_WORK) {
|
|
|
|
for (i=0; i<projects.size(); ++i) {
|
|
|
|
projects[i]->work_request = 0;
|
2004-06-30 01:10:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return urgency;
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// called from the client's polling loop.
|
|
|
|
// initiate scheduler RPC activity if needed and possible
|
|
|
|
//
|
2004-10-14 22:01:05 +00:00
|
|
|
bool CLIENT_STATE::scheduler_rpc_poll(double now) {
|
2004-07-14 20:55:26 +00:00
|
|
|
int urgency = DONT_NEED_WORK;
|
|
|
|
PROJECT *p;
|
|
|
|
bool action=false;
|
2004-10-14 22:01:05 +00:00
|
|
|
static double last_time=0;
|
|
|
|
|
|
|
|
if (now - last_time < 1.0) return false;
|
|
|
|
last_time = now;
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
switch(scheduler_op->state) {
|
|
|
|
case SCHEDULER_OP_STATE_IDLE:
|
2004-08-05 21:42:26 +00:00
|
|
|
if (network_suspended) break;
|
2004-07-14 20:55:26 +00:00
|
|
|
urgency = compute_work_requests();
|
|
|
|
|
|
|
|
// highest priority is to report overdue results
|
|
|
|
//
|
|
|
|
p = find_project_with_overdue_results();
|
|
|
|
if (p) {
|
2004-09-22 22:09:54 +00:00
|
|
|
scheduler_op->init_return_results(p);
|
2004-07-14 20:55:26 +00:00
|
|
|
action = true;
|
|
|
|
} else if (!(exit_when_idle && contacted_sched_server) && urgency != DONT_NEED_WORK) {
|
|
|
|
if (urgency == NEED_WORK) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
2004-08-05 09:35:30 +00:00
|
|
|
"May run out of work in %.2f days; requesting more",
|
2004-07-14 20:55:26 +00:00
|
|
|
global_prefs.work_buf_min_days
|
|
|
|
);
|
|
|
|
} else if (urgency == NEED_WORK_IMMEDIATELY) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
2004-08-05 09:35:30 +00:00
|
|
|
"Insufficient work; requesting more"
|
2004-07-14 20:55:26 +00:00
|
|
|
);
|
2004-06-17 20:39:38 +00:00
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
scheduler_op->init_get_work();
|
2003-02-13 23:02:45 +00:00
|
|
|
action = true;
|
2003-02-14 08:22:55 +00:00
|
|
|
} else if ((p=next_project_master_pending())) {
|
2003-02-13 23:02:45 +00:00
|
|
|
scheduler_op->init_get_work();
|
|
|
|
action = true;
|
2003-02-14 08:22:55 +00:00
|
|
|
} else if ((p=next_project_sched_rpc_pending())) {
|
2004-09-22 22:09:54 +00:00
|
|
|
scheduler_op->init_return_results(p);
|
2002-07-15 05:34:32 +00:00
|
|
|
action = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
scheduler_op->poll();
|
|
|
|
if (scheduler_op->state == SCHEDULER_OP_STATE_IDLE) {
|
|
|
|
action = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
// Handle the reply from a scheduler
|
2002-07-15 23:21:20 +00:00
|
|
|
//
|
2003-01-02 23:12:05 +00:00
|
|
|
int CLIENT_STATE::handle_scheduler_reply(
|
|
|
|
PROJECT* project, char* scheduler_url, int& nresults
|
2002-07-15 05:34:32 +00:00
|
|
|
) {
|
2002-04-30 22:22:54 +00:00
|
|
|
SCHEDULER_REPLY sr;
|
|
|
|
FILE* f;
|
|
|
|
int retval;
|
|
|
|
unsigned int i;
|
2004-10-01 08:15:58 +00:00
|
|
|
bool signature_valid, update_global_prefs=false, update_project_prefs=false;
|
2004-09-22 22:09:54 +00:00
|
|
|
char buf[256], filename[256];
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2003-01-02 23:12:05 +00:00
|
|
|
nresults = 0;
|
2002-04-30 22:22:54 +00:00
|
|
|
contacted_sched_server = true;
|
2004-04-08 08:15:23 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
get_sched_reply_filename(*project, filename);
|
|
|
|
scope_messages.printf_file(filename, "reply: ");
|
|
|
|
|
|
|
|
f = fopen(filename, "r");
|
2003-01-02 23:12:05 +00:00
|
|
|
if (!f) return ERR_FOPEN;
|
2003-07-03 05:01:29 +00:00
|
|
|
retval = sr.parse(f, project);
|
2002-08-29 04:19:51 +00:00
|
|
|
fclose(f);
|
2003-02-08 00:22:38 +00:00
|
|
|
if (retval) return retval;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2004-06-22 22:56:50 +00:00
|
|
|
if (sr.request_delay) {
|
2004-10-25 20:16:30 +00:00
|
|
|
double x = dtime() + sr.request_delay;
|
2004-06-22 22:56:50 +00:00
|
|
|
if (x > project->min_rpc_time) project->min_rpc_time = x;
|
|
|
|
}
|
|
|
|
|
2002-05-17 22:33:57 +00:00
|
|
|
if (strlen(sr.message)) {
|
2003-12-02 22:47:32 +00:00
|
|
|
sprintf(buf, "Message from server: %s", sr.message);
|
2003-03-06 17:42:49 +00:00
|
|
|
int prio = (!strcmp(sr.message_priority, "high"))?MSG_ERROR:MSG_INFO;
|
2003-12-02 22:47:32 +00:00
|
|
|
show_message(project, buf, prio);
|
2002-05-17 22:33:57 +00:00
|
|
|
}
|
|
|
|
|
2004-06-22 22:56:50 +00:00
|
|
|
// if project is down, return error (so that we back off)
|
|
|
|
// and don't do anything else
|
|
|
|
//
|
|
|
|
if (sr.project_is_down) {
|
|
|
|
return ERR_PROJECT_DOWN;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2002-09-29 00:32:11 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
if (sr.hostid) {
|
2004-10-01 08:15:58 +00:00
|
|
|
project->hostid = sr.hostid;
|
2002-04-30 22:22:54 +00:00
|
|
|
project->rpc_seqno = 0;
|
2004-10-01 08:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// see if we have a new venue from this project
|
|
|
|
//
|
|
|
|
if (strlen(sr.host_venue) && strcmp(project->host_venue, sr.host_venue)) {
|
|
|
|
safe_strcpy(project->host_venue, sr.host_venue);
|
|
|
|
msg_printf(project, MSG_INFO, "New host venue: %s", sr.host_venue);
|
|
|
|
update_project_prefs = true;
|
|
|
|
if (project == global_prefs_source_project()) {
|
|
|
|
strcpy(main_host_venue, sr.host_venue);
|
|
|
|
update_global_prefs = true;
|
2004-08-12 13:36:05 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
// if the scheduler reply includes global preferences,
|
|
|
|
// insert extra elements, write to disk, and parse
|
2002-06-21 06:52:47 +00:00
|
|
|
//
|
2002-09-29 00:32:11 +00:00
|
|
|
if (sr.global_prefs_xml) {
|
2003-12-24 00:50:51 +00:00
|
|
|
f = boinc_fopen(GLOBAL_PREFS_FILE_NAME, "w");
|
2003-01-02 23:12:05 +00:00
|
|
|
if (!f) return ERR_FOPEN;
|
2002-06-21 06:52:47 +00:00
|
|
|
fprintf(f,
|
2002-09-29 00:32:11 +00:00
|
|
|
"<global_preferences>\n"
|
2004-03-23 01:44:47 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// tag with the project and scheduler URL,
|
|
|
|
// but only if not already tagged
|
|
|
|
//
|
|
|
|
if (!strstr(sr.global_prefs_xml, "<source_project>")) {
|
|
|
|
fprintf(f,
|
|
|
|
" <source_project>%s</source_project>\n"
|
|
|
|
" <source_scheduler>%s</source_scheduler>\n",
|
|
|
|
project->master_url,
|
|
|
|
scheduler_url
|
|
|
|
);
|
|
|
|
}
|
|
|
|
fprintf(f,
|
2002-09-29 00:32:11 +00:00
|
|
|
"%s"
|
|
|
|
"</global_preferences>\n",
|
|
|
|
sr.global_prefs_xml
|
2002-06-21 06:52:47 +00:00
|
|
|
);
|
2003-08-14 00:02:15 +00:00
|
|
|
fclose(f);
|
2004-10-01 08:15:58 +00:00
|
|
|
update_global_prefs = true;
|
2003-08-13 20:00:20 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 08:15:58 +00:00
|
|
|
if (update_global_prefs) {
|
2004-03-30 23:05:34 +00:00
|
|
|
bool found_venue;
|
|
|
|
retval = global_prefs.parse_file(
|
2004-10-01 08:15:58 +00:00
|
|
|
GLOBAL_PREFS_FILE_NAME, project->host_venue, found_venue
|
2004-03-30 23:05:34 +00:00
|
|
|
);
|
|
|
|
if (retval) {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "Can't parse general preferences");
|
2004-03-30 23:05:34 +00:00
|
|
|
} else {
|
|
|
|
show_global_prefs_source(found_venue);
|
|
|
|
install_global_prefs();
|
|
|
|
}
|
2002-09-29 00:32:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// deal with project preferences (should always be there)
|
2003-11-28 19:19:11 +00:00
|
|
|
// If they've changed, write to account file,
|
|
|
|
// then parse to get our venue, and pass to running apps
|
2002-09-29 00:32:11 +00:00
|
|
|
//
|
|
|
|
if (sr.project_prefs_xml) {
|
2003-11-28 19:19:11 +00:00
|
|
|
if (strcmp(project->project_prefs.c_str(), sr.project_prefs_xml)) {
|
|
|
|
project->project_prefs = string(sr.project_prefs_xml);
|
2004-10-01 08:15:58 +00:00
|
|
|
update_project_prefs = true;
|
2003-05-20 00:03:39 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-10-01 08:15:58 +00:00
|
|
|
if (update_project_prefs) {
|
2004-10-01 18:48:34 +00:00
|
|
|
retval = project->write_account_file();
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "Can't write account file: %d", retval);
|
|
|
|
return retval;
|
|
|
|
}
|
2004-10-01 08:15:58 +00:00
|
|
|
project->parse_account_file();
|
|
|
|
project->parse_preferences_for_user_files();
|
|
|
|
active_tasks.request_reread_prefs(project);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-07-07 20:39:24 +00:00
|
|
|
// if the scheduler reply includes a code-signing key,
|
|
|
|
// accept it if we don't already have one from the project.
|
|
|
|
// Otherwise verify its signature, using the key we already have.
|
|
|
|
//
|
|
|
|
|
|
|
|
if (sr.code_sign_key) {
|
2003-02-11 00:52:44 +00:00
|
|
|
if (!strlen(project->code_sign_key)) {
|
2003-04-03 18:35:40 +00:00
|
|
|
safe_strcpy(project->code_sign_key, sr.code_sign_key);
|
2002-07-07 20:39:24 +00:00
|
|
|
} else {
|
2002-08-25 07:54:33 +00:00
|
|
|
if (sr.code_sign_key_signature) {
|
|
|
|
retval = verify_string2(
|
|
|
|
sr.code_sign_key, sr.code_sign_key_signature,
|
|
|
|
project->code_sign_key, signature_valid
|
|
|
|
);
|
|
|
|
if (!retval && signature_valid) {
|
2003-04-03 18:35:40 +00:00
|
|
|
safe_strcpy(project->code_sign_key, sr.code_sign_key);
|
2002-08-25 07:54:33 +00:00
|
|
|
} else {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "New code signing key doesn't validate");
|
2002-08-25 07:54:33 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "Missing code sign key signature");
|
2002-08-25 07:54:33 +00:00
|
|
|
}
|
2002-07-07 20:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy new entities to client state
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
for (i=0; i<sr.apps.size(); i++) {
|
|
|
|
APP* app = lookup_app(project, sr.apps[i].name);
|
2003-05-20 22:32:03 +00:00
|
|
|
if (!app) {
|
2002-04-30 22:22:54 +00:00
|
|
|
app = new APP;
|
|
|
|
*app = sr.apps[i];
|
|
|
|
retval = link_app(project, app);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link app %s in sched reply", app->name
|
|
|
|
);
|
|
|
|
delete app;
|
|
|
|
} else {
|
|
|
|
apps.push_back(app);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-06 17:37:58 +00:00
|
|
|
FILE_INFO* fip;
|
2002-04-30 22:22:54 +00:00
|
|
|
for (i=0; i<sr.file_infos.size(); i++) {
|
2004-07-06 17:37:58 +00:00
|
|
|
fip = lookup_file_info(project, sr.file_infos[i].name);
|
2004-08-12 10:13:01 +00:00
|
|
|
if (fip) {
|
2004-07-06 18:31:56 +00:00
|
|
|
fip->merge_info(sr.file_infos[i]);
|
|
|
|
} else {
|
2004-07-06 17:37:58 +00:00
|
|
|
fip = new FILE_INFO;
|
2002-04-30 22:22:54 +00:00
|
|
|
*fip = sr.file_infos[i];
|
2004-09-22 21:08:26 +00:00
|
|
|
retval = link_file_info(project, fip);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link file_info %s in sched reply", fip->name
|
|
|
|
);
|
|
|
|
delete fip;
|
|
|
|
} else {
|
|
|
|
file_infos.push_back(fip);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-08-05 21:42:26 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<sr.file_deletes.size(); i++) {
|
|
|
|
fip = lookup_file_info(project, sr.file_deletes[i].text);
|
2004-08-12 10:13:01 +00:00
|
|
|
if (fip) {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_INFO, "Got request to delete file: %s\n", fip->name);
|
2004-08-05 21:42:26 +00:00
|
|
|
fip->sticky = false;
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<sr.app_versions.size(); i++) {
|
|
|
|
APP* app = lookup_app(project, sr.app_versions[i].app_name);
|
2003-05-20 22:32:03 +00:00
|
|
|
APP_VERSION* avp = lookup_app_version(app, sr.app_versions[i].version_num);
|
2004-09-02 16:23:21 +00:00
|
|
|
if (avp) {
|
|
|
|
// if we had download failures, clear them
|
|
|
|
//
|
|
|
|
avp->clear_errors();
|
|
|
|
continue;
|
|
|
|
}
|
2004-08-16 14:30:41 +00:00
|
|
|
avp = new APP_VERSION;
|
|
|
|
*avp = sr.app_versions[i];
|
|
|
|
retval = link_app_version(project, avp);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link app version %s %d in sched reply",
|
|
|
|
avp->app_name, avp->version_num
|
|
|
|
);
|
|
|
|
delete avp;
|
|
|
|
continue;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-08-16 14:30:41 +00:00
|
|
|
app_versions.push_back(avp);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<sr.workunits.size(); i++) {
|
2004-08-16 14:30:41 +00:00
|
|
|
if (lookup_workunit(project, sr.workunits[i].name)) continue;
|
|
|
|
WORKUNIT* wup = new WORKUNIT;
|
|
|
|
*wup = sr.workunits[i];
|
|
|
|
int vnum = choose_version_num(wup->app_name, sr);
|
|
|
|
if (vnum < 0) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't find app version for WU %s", wup->name
|
|
|
|
);
|
|
|
|
delete wup;
|
|
|
|
continue;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-08-16 14:30:41 +00:00
|
|
|
|
|
|
|
wup->version_num = vnum;
|
|
|
|
retval = link_workunit(project, wup);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link workunit %s in sched reply", wup->name
|
|
|
|
);
|
|
|
|
delete wup;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
workunits.push_back(wup);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<sr.results.size(); i++) {
|
2004-08-16 14:30:41 +00:00
|
|
|
if (lookup_result(project, sr.results[i].name)) {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Already have result %s\n", sr.results[i].name
|
|
|
|
);
|
2004-08-16 14:30:41 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
RESULT* rp = new RESULT;
|
|
|
|
*rp = sr.results[i];
|
|
|
|
retval = link_result(project, rp);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link result %s in sched reply", rp->name
|
|
|
|
);
|
|
|
|
delete rp;
|
|
|
|
continue;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-08-16 14:30:41 +00:00
|
|
|
results.push_back(rp);
|
|
|
|
rp->state = RESULT_NEW;
|
|
|
|
nresults++;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// update records for ack'ed results
|
|
|
|
//
|
|
|
|
for (i=0; i<sr.result_acks.size(); i++) {
|
|
|
|
RESULT* rp = lookup_result(project, sr.result_acks[i].name);
|
2004-11-03 22:13:13 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::handle_scheduler_reply(): got ack for result %s\n",
|
|
|
|
sr.result_acks[i].name
|
|
|
|
);
|
2002-04-30 22:22:54 +00:00
|
|
|
if (rp) {
|
2003-09-23 23:19:41 +00:00
|
|
|
rp->got_server_ack = true;
|
2002-04-30 22:22:54 +00:00
|
|
|
} else {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
2004-11-04 19:10:56 +00:00
|
|
|
"Got ack for result %s, can't find", sr.result_acks[i].name
|
2003-06-17 18:59:36 +00:00
|
|
|
);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-08 00:27:59 +00:00
|
|
|
|
|
|
|
// remove acked trickle files
|
|
|
|
//
|
2004-07-06 04:01:15 +00:00
|
|
|
if (sr.message_ack) {
|
2004-01-08 00:27:59 +00:00
|
|
|
remove_trickle_files(project);
|
|
|
|
}
|
2004-07-06 18:31:56 +00:00
|
|
|
if (sr.send_file_list) {
|
|
|
|
project->send_file_list = true;
|
|
|
|
}
|
2003-02-13 23:02:45 +00:00
|
|
|
project->sched_rpc_pending = false;
|
2002-08-22 21:29:58 +00:00
|
|
|
set_client_state_dirty("handle_scheduler_reply");
|
2003-07-02 02:02:18 +00:00
|
|
|
scope_messages.printf("CLIENT_STATE::handle_scheduler_reply(): State after handle_scheduler_reply():\n");
|
|
|
|
print_summary();
|
2003-01-02 23:12:05 +00:00
|
|
|
return 0;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|