mirror of https://github.com/BOINC/boinc.git
- simulator work
- fix some indentation svn path=/trunk/boinc/; revision=22891
This commit is contained in:
parent
6784283211
commit
eeab2aee92
|
@ -44,3 +44,9 @@ David 6 Jan 2011
|
|||
server_status.php
|
||||
client/
|
||||
*.cpp
|
||||
|
||||
David 6 Jan 2011
|
||||
- simulator work
|
||||
- fix some indentation
|
||||
|
||||
various files
|
||||
|
|
|
@ -821,7 +821,7 @@ void html_start() {
|
|||
exit(1);
|
||||
}
|
||||
setbuf(html_out, 0);
|
||||
fprintf(index_file, "<br><a href=%s>Timeline</a>\n", buf);
|
||||
fprintf(index_file, "<br><a href=%s>Timeline</a>\n", TIMELINE_FNAME);
|
||||
fprintf(html_out, "<h2>BOINC client simulator</h2>\n");
|
||||
fprintf(html_out,
|
||||
"<table border=0 cellpadding=4><tr><th width=%d>Time</th>\n", WIDTH1
|
||||
|
@ -940,7 +940,7 @@ void make_graph(const char* title, const char* fname, int field) {
|
|||
fclose(f);
|
||||
sprintf(png_fname, "%s%s.png", outfile_prefix, fname);
|
||||
sprintf(cmd, "gnuplot < %s > %s", gp_fname, png_fname);
|
||||
fprintf(index_file, "<br><a href=%s>Graph of %s</a>\n", png_fname, title);
|
||||
fprintf(index_file, "<br><a href=%s.png>Graph of %s</a>\n", fname, title);
|
||||
system(cmd);
|
||||
}
|
||||
|
||||
|
@ -1006,7 +1006,7 @@ void make_graph(const char* title, const char* fname, int field, int nfields) {
|
|||
fclose(f);
|
||||
sprintf(png_fname, "%s%s.png", outfile_prefix, fname);
|
||||
sprintf(cmd, "gnuplot < %s > %s", gp_fname, png_fname);
|
||||
fprintf(index_file, "<br><a href=%s>Graph of %s</a>\n", png_fname, title);
|
||||
fprintf(index_file, "<br><a href=%s.png>Graph of %s</a>\n", fname, title);
|
||||
system(cmd);
|
||||
}
|
||||
|
||||
|
@ -1234,10 +1234,14 @@ void cull_projects() {
|
|||
void do_client_simulation() {
|
||||
char buf[256], buf2[256];
|
||||
|
||||
fprintf(index_file,
|
||||
"<h2>Input files</h2>\n"
|
||||
);
|
||||
|
||||
sprintf(buf, "%s%s", infile_prefix, CONFIG_FILE);
|
||||
read_config_file(true, buf);
|
||||
fprintf(index_file,
|
||||
"<br><a href=%s>Configuration file (cc_config.xml)</a>\n",
|
||||
"<br><a href=../../%s>Configuration file (cc_config.xml)</a>\n",
|
||||
buf
|
||||
);
|
||||
config.show();
|
||||
|
@ -1246,18 +1250,18 @@ void do_client_simulation() {
|
|||
sprintf(buf, "%s%s", infile_prefix, STATE_FILE_NAME);
|
||||
gstate.parse_state_file_aux(buf);
|
||||
fprintf(index_file,
|
||||
"<br><a href=%s>State file (client_state.xml)</a>\n",
|
||||
"<br><a href=../../%s>State file (client_state.xml)</a>\n",
|
||||
buf
|
||||
);
|
||||
sprintf(buf, "%s%s", infile_prefix, GLOBAL_PREFS_FILE_NAME);
|
||||
sprintf(buf2, "%s%s", infile_prefix, GLOBAL_PREFS_OVERRIDE_FILE);
|
||||
gstate.read_global_prefs(buf, buf2);
|
||||
fprintf(index_file,
|
||||
"<br><a href=%s>Preferences file (global_prefs.xml)</a>\n"
|
||||
"<br><a href=%s>Preferences override file (global_prefs_override.xml)</a>\n"
|
||||
"<br><a href=../../%s>Preferences file (global_prefs.xml)</a>\n"
|
||||
"<br><a href=../../%s>Preferences override file (global_prefs_override.xml)</a>\n"
|
||||
"<h2>Output files</h2>\n"
|
||||
"<a href=%s>Log file</a>\n",
|
||||
buf, buf2, log_filename
|
||||
buf, buf2, LOG_FNAME
|
||||
);
|
||||
|
||||
get_app_params();
|
||||
|
@ -1351,9 +1355,6 @@ int main(int argc, char** argv) {
|
|||
|
||||
sprintf(buf, "%s%s", outfile_prefix, "index.html");
|
||||
index_file = fopen(buf, "w");
|
||||
fprintf(index_file,
|
||||
"<h2>Input files</h2>\n"
|
||||
);
|
||||
|
||||
sprintf(log_filename, "%s%s", outfile_prefix, LOG_FNAME);
|
||||
logfile = fopen(log_filename, "w");
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
// show the average results as a function of the parameter.
|
||||
// Show the figures of merit as line graphs.
|
||||
|
||||
$duration = 86400; // sim duration
|
||||
$duration = 864000; // sim duration
|
||||
|
||||
// a set of scheduling policies
|
||||
//
|
||||
|
@ -261,4 +261,11 @@ if (0) {
|
|||
compare_params(array("s3"), $p, $lo, $hi, $inc, "test2");
|
||||
}
|
||||
|
||||
if (1) {
|
||||
$p1 = new POLICY();
|
||||
$p2 = new POLICY();
|
||||
$p2->use_hyst_fetch = true;
|
||||
compare_policies(array("scen1"), $p1, $p2, "test3");
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
using std::vector;
|
||||
|
||||
bool use_rec = false;
|
||||
bool use_hysteresis = false;
|
||||
bool use_hyst_fetch = false;
|
||||
|
||||
RSC_WORK_FETCH cuda_work_fetch;
|
||||
RSC_WORK_FETCH ati_work_fetch;
|
||||
|
@ -975,7 +975,7 @@ if (use_rec) {
|
|||
bool cuda_usable = gstate.host_info.have_cuda() && gpus_usable;
|
||||
bool ati_usable = gstate.host_info.have_ati() && gpus_usable;
|
||||
|
||||
if (use_hysteresis) {
|
||||
if (use_hyst_fetch) {
|
||||
if (cuda_usable) {
|
||||
p = cuda_work_fetch.choose_project_hyst();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ extern bool use_rec;
|
|||
#define REC_HALF_LIFE (10*86400)
|
||||
//#define REC_HALF_LIFE (1*86400)
|
||||
|
||||
extern bool use_hysteresis;
|
||||
extern bool use_hyst_fetch;
|
||||
|
||||
#define RSC_TYPE_ANY 0
|
||||
#define RSC_TYPE_CPU 1
|
||||
|
|
|
@ -283,7 +283,7 @@ bool str_replace(char* str, const char* substr, const char* replacement) {
|
|||
strcat(p, temp);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// if the given XML has an element of the form
|
||||
// <venue name="venue_name">
|
||||
// ...
|
||||
|
@ -309,17 +309,17 @@ void extract_venue(const char* in, const char* venue_name, char* out) {
|
|||
//
|
||||
q = in;
|
||||
strcpy(out, "");
|
||||
while (1) {
|
||||
p = strstr(q, "<venue");
|
||||
if (!p) {
|
||||
strcat(out, q);
|
||||
while (1) {
|
||||
p = strstr(q, "<venue");
|
||||
if (!p) {
|
||||
strcat(out, q);
|
||||
break;
|
||||
}
|
||||
strncat(out, q, p-q);
|
||||
q = strstr(p, "</venue>");
|
||||
if (!q) break;
|
||||
q += strlen("</venue>");
|
||||
}
|
||||
strncat(out, q, p-q);
|
||||
q = strstr(p, "</venue>");
|
||||
if (!q) break;
|
||||
q += strlen("</venue>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,6 @@ int skip_unrecognized(char* buf, MIOFILE& fin) {
|
|||
if (strstr(buf2, close_tag.c_str())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
@ -608,7 +607,7 @@ bool XML_PARSER::copy_until_tag(char* buf, int len) {
|
|||
int XML_PARSER::get_aux(char* buf, int len, char* attr_buf, int attr_len) {
|
||||
bool eof;
|
||||
int c, retval;
|
||||
|
||||
|
||||
while (1) {
|
||||
eof = scan_nonws(c);
|
||||
if (eof) return XML_PARSE_EOF;
|
||||
|
@ -838,27 +837,27 @@ bool XML_PARSER::parse_start(const char* start_tag) {
|
|||
// strips whitespace.
|
||||
//
|
||||
int XML_PARSER::element_contents(const char* end_tag, char* buf, int buflen) {
|
||||
int n=0;
|
||||
int retval=0;
|
||||
int n=0;
|
||||
int retval=0;
|
||||
while (1) {
|
||||
if (n == buflen-1) {
|
||||
retval = ERR_XML_PARSE;
|
||||
break;
|
||||
}
|
||||
if (n == buflen-1) {
|
||||
retval = ERR_XML_PARSE;
|
||||
break;
|
||||
}
|
||||
int c = f->_getc();
|
||||
if (c == EOF) {
|
||||
retval = ERR_XML_PARSE;
|
||||
break;
|
||||
}
|
||||
buf[n++] = c;
|
||||
buf[n] = 0;
|
||||
char* p = strstr(buf, end_tag);
|
||||
if (p) {
|
||||
*p = 0;
|
||||
break;
|
||||
}
|
||||
if (c == EOF) {
|
||||
retval = ERR_XML_PARSE;
|
||||
break;
|
||||
}
|
||||
buf[n++] = c;
|
||||
buf[n] = 0;
|
||||
char* p = strstr(buf, end_tag);
|
||||
if (p) {
|
||||
*p = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
buf[n] = 0;
|
||||
buf[n] = 0;
|
||||
strip_whitespace(buf);
|
||||
return retval;
|
||||
}
|
||||
|
|
30
lib/url.cpp
30
lib/url.cpp
|
@ -245,12 +245,12 @@ void escape_url_readable(char *in, char* out) {
|
|||
void canonicalize_master_url(char* url) {
|
||||
char buf[1024];
|
||||
size_t n;
|
||||
bool bSSL = false; // keep track if they sent in https://
|
||||
bool bSSL = false; // keep track if they sent in https://
|
||||
|
||||
char *p = strstr(url, "://");
|
||||
if (p) {
|
||||
bSSL = (bool) (p == url + 5);
|
||||
strcpy(buf, p+3);
|
||||
bSSL = (bool) (p == url + 5);
|
||||
strcpy(buf, p+3);
|
||||
} else {
|
||||
strcpy(buf, url);
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ void canonicalize_master_url(char* url) {
|
|||
if (buf[n-1] != '/') {
|
||||
strcat(buf, "/");
|
||||
}
|
||||
sprintf(url, "http%s://%s", (bSSL ? "s" : ""), buf);
|
||||
sprintf(url, "http%s://%s", (bSSL ? "s" : ""), buf);
|
||||
}
|
||||
|
||||
void canonicalize_master_url(string& url) {
|
||||
|
@ -278,19 +278,19 @@ void canonicalize_master_url(string& url) {
|
|||
bool valid_master_url(char* buf) {
|
||||
char* p, *q;
|
||||
size_t n;
|
||||
bool bSSL = false;
|
||||
bool bSSL = false;
|
||||
|
||||
p = strstr(buf, "http://");
|
||||
if (p != buf) {
|
||||
// allow https
|
||||
p = strstr(buf, "https://");
|
||||
if (p == buf) {
|
||||
bSSL = true;
|
||||
} else {
|
||||
return false; // no http or https, it's bad!
|
||||
}
|
||||
}
|
||||
q = p+strlen(bSSL ? "https://" : "http://");
|
||||
if (p != buf) {
|
||||
// allow https
|
||||
p = strstr(buf, "https://");
|
||||
if (p == buf) {
|
||||
bSSL = true;
|
||||
} else {
|
||||
return false; // no http or https, it's bad!
|
||||
}
|
||||
}
|
||||
q = p+strlen(bSSL ? "https://" : "http://");
|
||||
p = strstr(q, ".");
|
||||
if (!p) return false;
|
||||
if (p == q) return false;
|
||||
|
|
|
@ -308,9 +308,9 @@ double linux_cpu_time(int pid) {
|
|||
|
||||
void boinc_crash() {
|
||||
#ifdef _WIN32
|
||||
DebugBreak();
|
||||
DebugBreak();
|
||||
#else
|
||||
*(int*)0 = 0;
|
||||
*(int*)0 = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,13 @@
|
|||
* Find out if we are on a Windows 2000 compatible system
|
||||
**/
|
||||
BOOL IsWindows2000Compatible() {
|
||||
OSVERSIONINFO osvi;
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
OSVERSIONINFO osvi;
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
|
||||
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
|
||||
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (osvi.dwMajorVersion >= 5);
|
||||
}
|
||||
|
@ -800,16 +801,16 @@ int suspend_or_resume_threads(
|
|||
}
|
||||
|
||||
void chdir_to_data_dir() {
|
||||
LONG lReturnValue;
|
||||
HKEY hkSetupHive;
|
||||
LONG lReturnValue;
|
||||
HKEY hkSetupHive;
|
||||
LPTSTR lpszRegistryValue = NULL;
|
||||
DWORD dwSize = 0;
|
||||
DWORD dwSize = 0;
|
||||
|
||||
// change the current directory to the boinc data directory if it exists
|
||||
lReturnValue = RegOpenKeyEx(
|
||||
lReturnValue = RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
_T("SOFTWARE\\Space Sciences Laboratory, U.C. Berkeley\\BOINC Setup"),
|
||||
0,
|
||||
0,
|
||||
KEY_READ,
|
||||
&hkSetupHive
|
||||
);
|
||||
|
@ -842,7 +843,7 @@ void chdir_to_data_dir() {
|
|||
}
|
||||
}
|
||||
|
||||
if (hkSetupHive) RegCloseKey(hkSetupHive);
|
||||
if (hkSetupHive) RegCloseKey(hkSetupHive);
|
||||
if (lpszRegistryValue) free(lpszRegistryValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ bool do_pass(APP& app) {
|
|||
assimilate_state = ASSIMILATE_INIT;
|
||||
}
|
||||
sprintf(
|
||||
buf, "assimilate_state=%d, transition_time=%d",
|
||||
buf, "assimilate_state=%d, transition_time=%d",
|
||||
assimilate_state, (int)time(0)
|
||||
);
|
||||
retval = wu.update_field(buf);
|
||||
|
@ -230,7 +230,7 @@ int main(int argc, char** argv) {
|
|||
// your project.
|
||||
update_db = false;
|
||||
} else if (is_arg(argv[i], "noinsert")) {
|
||||
// This option is also for testing and is used to
|
||||
// This option is also for testing and is used to
|
||||
// prevent the inserting of results into the *backend*
|
||||
// (as opposed to the boinc) DB.
|
||||
noinsert = true;
|
||||
|
@ -282,11 +282,11 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
install_stop_signal_handler();
|
||||
do {
|
||||
if (!do_pass(app)) {
|
||||
if (!one_pass) {
|
||||
sleep(sleep_interval);
|
||||
if (!do_pass(app)) {
|
||||
if (!one_pass) {
|
||||
sleep(sleep_interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (!one_pass);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,23 +108,23 @@ void mark_edf_misses (int ncpus, vector<IP_RESULT>& ip_results){
|
|||
lowest_booked_cpu = j;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
booked_to[lowest_booked_cpu] += r.cpu_time_remaining;
|
||||
log_msg(DETAIL, "[edf_detail] running %s on cpu %d; finishes at %.2f\n",
|
||||
r.name, lowest_booked_cpu, booked_to[lowest_booked_cpu]/3600
|
||||
);
|
||||
if (booked_to[lowest_booked_cpu] > r.computation_deadline) {
|
||||
r.misses_deadline = true;
|
||||
r.estimated_completion_time = booked_to[lowest_booked_cpu];
|
||||
log_msg(DETAIL, "[edf_detail] %s misses_deadline; est completion %.2f\n",
|
||||
r.misses_deadline = true;
|
||||
r.estimated_completion_time = booked_to[lowest_booked_cpu];
|
||||
log_msg(DETAIL, "[edf_detail] %s misses_deadline; est completion %.2f\n",
|
||||
r.name, booked_to[lowest_booked_cpu]/3600
|
||||
);
|
||||
} else {
|
||||
r.misses_deadline = false;
|
||||
log_msg(DETAIL, "[edf_detail] %s makes deadline; est completion %.2f\n",
|
||||
r.misses_deadline = false;
|
||||
log_msg(DETAIL, "[edf_detail] %s makes deadline; est completion %.2f\n",
|
||||
r.name, booked_to[lowest_booked_cpu]/3600
|
||||
);
|
||||
// if result doesn't miss its deadline,
|
||||
// if result doesn't miss its deadline,
|
||||
// then the estimated_completion_time is of no use
|
||||
}
|
||||
}
|
||||
|
@ -158,24 +158,24 @@ void init_ip_results(
|
|||
}
|
||||
|
||||
#if 0
|
||||
// Sort test_results by computation_deadline.
|
||||
// Sort test_results by computation_deadline.
|
||||
// For each test result in ascending order of deadline,
|
||||
// see whether adding it to the work queue would cause deadline misses
|
||||
// or deadline miss delays.
|
||||
// If a test result passes these checks, append it to the work queue
|
||||
// for further result additions.
|
||||
// Return list of new results that can be sent to the client.
|
||||
// Return list of new results that can be sent to the client.
|
||||
//
|
||||
// NOTE: should we sort by increasing deadline or by increasing slack time?
|
||||
//
|
||||
vector<TEMP_RESULT> REQUEST_HANDLER_WORK_SEND::find_sendable_test_results (
|
||||
vector<TEMP_RESULT> test_results,
|
||||
int ncpus,
|
||||
vector<TEMP_RESULT> ipp_results,
|
||||
int ncpus,
|
||||
vector<TEMP_RESULT> ipp_results,
|
||||
double cpu_pessimism_factor // = 1 by default
|
||||
) {
|
||||
//test results to send
|
||||
vector<TEMP_RESULT> sendable_test_results;
|
||||
vector<TEMP_RESULT> sendable_test_results;
|
||||
vector<TEMP_RESULT>::iterator test_results_it;
|
||||
|
||||
sort(test_results.begin(), test_results.end(), lessthan_deadline);
|
||||
|
@ -214,7 +214,7 @@ vector<TEMP_RESULT> REQUEST_HANDLER_WORK_SEND::find_sendable_test_results (
|
|||
//
|
||||
bool check_candidate (
|
||||
IP_RESULT& candidate,
|
||||
int ncpus,
|
||||
int ncpus,
|
||||
vector<IP_RESULT> ip_results // passed by value (copy)
|
||||
) {
|
||||
double booked_to[128]; // keeps track of when each cpu is free
|
||||
|
@ -244,7 +244,7 @@ bool check_candidate (
|
|||
double lowest_booked_time = booked_to[0];
|
||||
int lowest_booked_cpu = 0;
|
||||
for (j=1; j<ncpus; j++) {
|
||||
if (booked_to[j] < lowest_booked_time) {
|
||||
if (booked_to[j] < lowest_booked_time) {
|
||||
lowest_booked_time = booked_to[j];
|
||||
lowest_booked_cpu = j;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ bool check_candidate (
|
|||
if (booked_to[lowest_booked_cpu] > r.computation_deadline
|
||||
&& !r.misses_deadline
|
||||
) {
|
||||
log_msg(SUMMARY,
|
||||
log_msg(SUMMARY,
|
||||
"[send] cand. fails; %s now misses deadline: %.2f > %.2f\n",
|
||||
r.name, booked_to[lowest_booked_cpu]/3600,
|
||||
r.computation_deadline/3600
|
||||
|
@ -270,7 +270,7 @@ bool check_candidate (
|
|||
// check a late result (i.e., one that would have missed its
|
||||
// deadline) // would be made even later
|
||||
//
|
||||
if (r.misses_deadline
|
||||
if (r.misses_deadline
|
||||
&& booked_to[lowest_booked_cpu] > r.estimated_completion_time
|
||||
){
|
||||
log_msg(SUMMARY,
|
||||
|
|
|
@ -362,12 +362,12 @@ static bool retrieve_single_trigger_by_fileset_name(char *fileset_name, DB_SCHED
|
|||
// (no way to be sure if it succeeded).
|
||||
//
|
||||
int make_more_work_for_file(char* filename) {
|
||||
int retval = 0;
|
||||
int retval = 0;
|
||||
DB_SCHED_TRIGGER trigger;
|
||||
|
||||
|
||||
if (!retrieve_single_trigger_by_fileset_name(filename, trigger)) {
|
||||
// trigger retrieval failed (message logged by previous method)
|
||||
// trigger retrieval failed (message logged by previous method)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -514,11 +514,11 @@ static int get_working_set_filename(char *filename, bool slowhost) {
|
|||
|
||||
|
||||
static void flag_for_possible_removal(char* fileset_name) {
|
||||
int retval = 0;
|
||||
int retval = 0;
|
||||
DB_SCHED_TRIGGER trigger;
|
||||
|
||||
if (!retrieve_single_trigger_by_fileset_name(fileset_name, trigger)) {
|
||||
// trigger retrieval failed (message logged by previous method)
|
||||
// trigger retrieval failed (message logged by previous method)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1198,13 +1198,13 @@ void send_work_locality() {
|
|||
// generate corresponding l1_XXXX.XX_S5R4 and *_S5R7 patterns and delete it also
|
||||
//
|
||||
if (strlen(fi.name)==15 && !strncmp("h1_", fi.name, 3)) {
|
||||
FILE_INFO fil4,fil7,fih7;
|
||||
fil4=fi;
|
||||
fil4.name[0]='l';
|
||||
fil7=fil4;
|
||||
fil7.name[14]='7';
|
||||
fih7=fi;
|
||||
fih7.name[14]='7';
|
||||
FILE_INFO fil4,fil7,fih7;
|
||||
fil4=fi;
|
||||
fil4.name[0]='l';
|
||||
fil7=fil4;
|
||||
fil7.name[14]='7';
|
||||
fih7=fi;
|
||||
fih7.name[14]='7';
|
||||
g_reply->file_deletes.push_back(fil4);
|
||||
g_reply->file_deletes.push_back(fil7);
|
||||
g_reply->file_deletes.push_back(fih7);
|
||||
|
|
|
@ -51,9 +51,9 @@ SCHED_MSG_LOG::~SCHED_MSG_LOG() {
|
|||
|
||||
void SCHED_MSG_LOG::close() {
|
||||
if (output) {
|
||||
flush();
|
||||
fclose(output);
|
||||
output = NULL;
|
||||
flush();
|
||||
fclose(output);
|
||||
output = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ struct WU_RESULT {
|
|||
int state;
|
||||
// EMPTY, PRESENT, or PID of locking process
|
||||
int infeasible_count;
|
||||
bool need_reliable; // try to send to a reliable host
|
||||
bool need_reliable; // try to send to a reliable host
|
||||
WORKUNIT workunit;
|
||||
int resultid;
|
||||
int time_added_to_shared_memory;
|
||||
|
|
|
@ -52,9 +52,9 @@ static int hostid=0;
|
|||
static int compare(const void *x, const void *y) {
|
||||
const URLTYPE *a=(const URLTYPE *)x;
|
||||
const URLTYPE *b=(const URLTYPE *)y;
|
||||
|
||||
|
||||
char longname[512];
|
||||
|
||||
|
||||
const int twelve_hours = 12*3600;
|
||||
|
||||
int diffa = abs(tzone - (a->zone));
|
||||
|
@ -63,7 +63,7 @@ static int compare(const void *x, const void *y) {
|
|||
if (diffa > twelve_hours) {
|
||||
diffa = 2*twelve_hours-diffa;
|
||||
}
|
||||
|
||||
|
||||
if (diffb > twelve_hours) {
|
||||
diffb = 2*twelve_hours-diffb;
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ static int compare(const void *x, const void *y) {
|
|||
if (diffa < diffb) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (diffa > diffb) {
|
||||
return +1;
|
||||
}
|
||||
|
||||
|
||||
// In order to ensure uniform distribution, we hash paths that are
|
||||
// equidistant from the host's timezone in a way that gives a
|
||||
// unique ordering for each host but which is effectively random
|
||||
|
@ -87,15 +87,15 @@ static int compare(const void *x, const void *y) {
|
|||
std::string sb = md5_string((const unsigned char *)longname, strlen((const char *)longname));
|
||||
int xa = strtol(sa.substr(1, 7).c_str(), 0, 16);
|
||||
int xb = strtol(sb.substr(1, 7).c_str(), 0, 16);
|
||||
|
||||
|
||||
if (xa<xb) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (xa>xb) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,13 @@ static URLTYPE *cached=NULL;
|
|||
URLTYPE* read_download_list() {
|
||||
int count=0;
|
||||
int i;
|
||||
|
||||
|
||||
if (cached) return cached;
|
||||
|
||||
const char *download_servers = config.project_path("download_servers");
|
||||
#ifndef _USING_FCGI_
|
||||
FILE *fp=fopen(download_servers, "r");
|
||||
#else
|
||||
#else
|
||||
FCGI_FILE *fp=FCGI::fopen(download_servers, "r");
|
||||
#endif
|
||||
|
||||
|
@ -142,7 +142,7 @@ URLTYPE* read_download_list() {
|
|||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
|
||||
if (!count) {
|
||||
log_messages.printf(MSG_CRITICAL,
|
||||
"File %s contained no valid entries!\n"
|
||||
|
@ -153,11 +153,11 @@ URLTYPE* read_download_list() {
|
|||
free(cached);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// sort URLs by distance from host timezone. See compare() above
|
||||
// for details.
|
||||
qsort(cached, count, sizeof(URLTYPE), compare);
|
||||
|
||||
|
||||
log_messages.printf(MSG_DEBUG,
|
||||
"Sorted list of URLs follows [host timezone: UTC%+d]\n",
|
||||
tzone
|
||||
|
@ -180,9 +180,9 @@ int make_download_list(char *buffer, char *path, unsigned int lim, int tz) {
|
|||
// global variable used in the compare() function
|
||||
tzone=tz;
|
||||
URLTYPE *serverlist=read_download_list();
|
||||
|
||||
|
||||
if (!serverlist) return -1;
|
||||
|
||||
|
||||
// print list of servers in sorted order.
|
||||
// Space is to format them nicely
|
||||
//
|
||||
|
@ -210,7 +210,7 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) {
|
|||
|
||||
p = (r = old_xml);
|
||||
|
||||
// search for next URL to do surgery on
|
||||
// search for next URL to do surgery on
|
||||
while ((q=strstr(p, "<url>"))) {
|
||||
// p is at current position
|
||||
// q is at beginning of next "<url>" tag
|
||||
|
@ -218,19 +218,19 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) {
|
|||
char *s;
|
||||
char path[1024];
|
||||
int len = q-p;
|
||||
|
||||
|
||||
// copy everything from p to q to new_xml
|
||||
//
|
||||
strncpy(new_xml, p, len);
|
||||
new_xml += len;
|
||||
|
||||
|
||||
// locate next instance of </url>
|
||||
//
|
||||
if (!(r = strstr(q, "</url>"))) {
|
||||
return 1;
|
||||
}
|
||||
r += strlen("</url>");
|
||||
|
||||
|
||||
// r points to the end of the whole "<url>...</url>" tag
|
||||
// parse out the URL into 'path'
|
||||
//
|
||||
|
@ -246,8 +246,8 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) {
|
|||
new_xml += r-q;
|
||||
p=r;
|
||||
} else {
|
||||
// calculate free space available for URL replaces
|
||||
int lim = total_free - (len - (p - old_xml));
|
||||
// calculate free space available for URL replaces
|
||||
int lim = total_free - (len - (p - old_xml));
|
||||
|
||||
// find end of the specified replace string,
|
||||
// i.e. start of the 'path'
|
||||
|
@ -256,10 +256,10 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) {
|
|||
// insert new download list in place of the original single URL
|
||||
len = make_download_list(new_xml, s, lim, tz);
|
||||
if (len == 0) {
|
||||
// if the replacement would exceed the maximum XML length,
|
||||
// just keep the original URL
|
||||
len = r-q;
|
||||
strncpy(new_xml, q, len);
|
||||
// if the replacement would exceed the maximum XML length,
|
||||
// just keep the original URL
|
||||
len = r-q;
|
||||
strncpy(new_xml, q, len);
|
||||
} else if (len < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) {
|
|||
p=r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
strcpy(new_xml, r);
|
||||
return 0;
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ void process_wu_timezone(
|
|||
|
||||
tzone = g_reply->host.timezone;
|
||||
hostid = g_reply->host.id;
|
||||
|
||||
|
||||
retval = add_download_servers(wu2.xml_doc, wu3.xml_doc, g_reply->host.timezone);
|
||||
if (retval) {
|
||||
log_messages.printf(MSG_CRITICAL,
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
// this records an app for which the user will accept work
|
||||
//
|
||||
struct APP_INFO {
|
||||
int appid;
|
||||
int work_available;
|
||||
int appid;
|
||||
int work_available;
|
||||
};
|
||||
|
||||
// represents a resource (disk etc.) that the client may not have enough of
|
||||
|
@ -184,7 +184,7 @@ struct BEST_APP_VERSION {
|
|||
|
||||
DB_HOST_APP_VERSION* host_app_version();
|
||||
// get the HOST_APP_VERSION, if any
|
||||
|
||||
|
||||
BEST_APP_VERSION() {
|
||||
present = false;
|
||||
cavp = NULL;
|
||||
|
@ -264,7 +264,7 @@ struct SCHEDULER_REQUEST {
|
|||
int core_client_version; // 10000*major + 100*minor + release
|
||||
int rpc_seqno;
|
||||
double work_req_seconds;
|
||||
// in "normalized CPU seconds" (see work_req.php)
|
||||
// in "normalized CPU seconds" (see work_req.php)
|
||||
double cpu_req_secs;
|
||||
double cpu_req_instances;
|
||||
double resource_share_fraction;
|
||||
|
@ -353,9 +353,9 @@ struct WORK_REQ {
|
|||
bool no_cuda;
|
||||
bool no_ati;
|
||||
bool no_cpu;
|
||||
bool allow_non_preferred_apps;
|
||||
bool allow_beta_work;
|
||||
std::vector<APP_INFO> preferred_apps;
|
||||
bool allow_non_preferred_apps;
|
||||
bool allow_beta_work;
|
||||
std::vector<APP_INFO> preferred_apps;
|
||||
|
||||
bool has_reliable_version;
|
||||
// whether the host has a reliable app version
|
||||
|
|
|
@ -150,8 +150,8 @@ void get_log_path(char* p, const char* filename) {
|
|||
}
|
||||
|
||||
static void filename_hash(const char* filename, int fanout, char* dir) {
|
||||
std::string s = md5_string((const unsigned char*)filename, strlen(filename));
|
||||
int x = strtol(s.substr(1, 7).c_str(), 0, 16);
|
||||
std::string s = md5_string((const unsigned char*)filename, strlen(filename));
|
||||
int x = strtol(s.substr(1, 7).c_str(), 0, 16);
|
||||
sprintf(dir, "%x", x % fanout);
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ static void filename_hash(const char* filename, int fanout, char* dir) {
|
|||
//
|
||||
int dir_hier_path(
|
||||
const char* filename, const char* root, int fanout,
|
||||
char* path, bool create
|
||||
char* path, bool create
|
||||
) {
|
||||
char dir[256], dirpath[256];
|
||||
int retval;
|
||||
|
@ -190,7 +190,7 @@ int dir_hier_path(
|
|||
//
|
||||
int dir_hier_url(
|
||||
const char* filename, const char* root, int fanout,
|
||||
char* result
|
||||
char* result
|
||||
) {
|
||||
char dir[256];
|
||||
|
||||
|
@ -272,13 +272,13 @@ bool is_arg(const char* x, const char* y) {
|
|||
|
||||
#ifdef GCL_SIMULATOR
|
||||
|
||||
void simulator_signal_handler(int signum){
|
||||
void simulator_signal_handler(int signum) {
|
||||
FILE *fsim;
|
||||
char currenttime[64];
|
||||
fsim = fopen(config.project_path("simulator/sim_time.txt"),"r");
|
||||
if(fsim){
|
||||
fscanf(fsim,"%s", currenttime);
|
||||
simtime = atof(currenttime);
|
||||
simtime = atof(currenttime);
|
||||
fclose(fsim);
|
||||
}
|
||||
log_messages.printf(MSG_NORMAL,
|
||||
|
|
|
@ -43,14 +43,14 @@ extern void get_log_path(char*, const char*);
|
|||
//
|
||||
extern int dir_hier_path(
|
||||
const char* filename, const char* root, int fanout,
|
||||
char* result, bool create=false
|
||||
char* result, bool create=false
|
||||
);
|
||||
|
||||
// convert filename to URL in a hierarchical directory system
|
||||
//
|
||||
extern int dir_hier_url(
|
||||
const char* filename, const char* root, int fanout,
|
||||
char* result
|
||||
char* result
|
||||
);
|
||||
|
||||
extern void compute_avg_turnaround(HOST& host, double turnaround);
|
||||
|
|
Loading…
Reference in New Issue