mirror of https://github.com/BOINC/boinc.git
- server code: at some point I made a global var "SCHED_CONFIG config",
mostly so that the parse function could assume that everything was initially zero. However, various back-end functions pass around SCHED_CONFIG& as an argument (also named "config"). This creates a shadow, which is always bad. Worse is the possibility that some projects have back-end programs that have a SCHED_CONFIG variable that's automatic, and therefore isn't zero initially, and therefore isn't parsing correctly. To fix this, I changed the 2 vectors in SCHED_CONFIG into pointers, and have the parse routine zero the structure. I was tempted to remove the SCHED_CONFIG& args to back-end functions, but this would have broken some projects' code. I did, however, change the name from config to config_loc to avoid shadowing. Also fixed various other compiler warnings. svn path=/trunk/boinc/; revision=15541
This commit is contained in:
parent
0d105ea386
commit
16b1305db7
|
@ -185,7 +185,7 @@ static int setup_shared_mem() {
|
|||
#else
|
||||
if (aid.shmem_seg_name == -1) {
|
||||
// Version 6 Unix/Linux/Mac client
|
||||
if (attach_shmem_mmap( MMAPPED_FILE_NAME, (void**)&app_client_shm->shm)) {
|
||||
if (attach_shmem_mmap(MMAPPED_FILE_NAME, (void**)&app_client_shm->shm)) {
|
||||
delete app_client_shm;
|
||||
app_client_shm = NULL;
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
// main loop - read characters, convert to UC, write
|
||||
//
|
||||
for (int i=0; ; i++) {
|
||||
for (i=0; ; i++) {
|
||||
c = fgetc(infile);
|
||||
|
||||
if (c == EOF) break;
|
||||
|
|
|
@ -5362,3 +5362,41 @@ Charlie 2 July 2008
|
|||
project.pbxproj
|
||||
win_build/
|
||||
boincmgr_curl.vcproj
|
||||
|
||||
David 2 July 2008
|
||||
- server code: at some point I made a global var "SCHED_CONFIG config",
|
||||
mostly so that the parse function could assume
|
||||
that everything was initially zero.
|
||||
However, various back-end functions pass around SCHED_CONFIG&
|
||||
as an argument (also named "config").
|
||||
This creates a shadow, which is always bad.
|
||||
Worse is the possibility that some projects have back-end programs
|
||||
that have a SCHED_CONFIG variable that's automatic,
|
||||
and therefore isn't zero initially,
|
||||
and therefore isn't parsing correctly.
|
||||
|
||||
To fix this, I changed the 2 vectors in SCHED_CONFIG into pointers,
|
||||
and have the parse routine zero the structure.
|
||||
I was tempted to remove the SCHED_CONFIG& args to back-end functions,
|
||||
but this would have broken some projects' code.
|
||||
I did, however, change the name from config to config_loc
|
||||
to avoid shadowing.
|
||||
|
||||
Also fixed various other compiler warnings.
|
||||
|
||||
api/
|
||||
boinc_api.C
|
||||
apps/
|
||||
upper_case.C
|
||||
lib/
|
||||
shmem.C,h
|
||||
sched/
|
||||
handle_request.C
|
||||
sched_array.C
|
||||
sched_assign.C
|
||||
sched_config.C,h
|
||||
sched_send.C
|
||||
server_types.C
|
||||
tools/
|
||||
backend_lib.C,h
|
||||
process_result_template.C
|
||||
|
|
|
@ -301,7 +301,7 @@ int detach_shmem(void* p) {
|
|||
|
||||
// V6 mmap() shared memory for Unix/Linux/Mac
|
||||
//
|
||||
int create_shmem_mmap(char *path, size_t size, void** pp) {
|
||||
int create_shmem_mmap(const char *path, size_t size, void** pp) {
|
||||
int fd, retval;
|
||||
struct stat sbuf;
|
||||
|
||||
|
@ -347,7 +347,7 @@ int destroy_shmem_mmap(key_t key){
|
|||
}
|
||||
|
||||
|
||||
int attach_shmem_mmap(char *path, void** pp) {
|
||||
int attach_shmem_mmap(const char *path, void** pp) {
|
||||
int fd, retval;
|
||||
struct stat sbuf;
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ int detach_shmem(HANDLE hSharedMem, void* p);
|
|||
#else
|
||||
#ifndef __EMX__
|
||||
#define MMAPPED_FILE_NAME "boinc_mmap_file"
|
||||
extern int create_shmem_mmap(char *path, size_t size, void** pp);
|
||||
extern int attach_shmem_mmap(char *path, void** pp);
|
||||
extern int create_shmem_mmap(const char *path, size_t size, void** pp);
|
||||
extern int attach_shmem_mmap(const char *path, void** pp);
|
||||
extern int detach_shmem_mmap(void* p, size_t size);
|
||||
#endif
|
||||
extern int create_shmem(key_t, int size, gid_t gid, void**);
|
||||
|
|
|
@ -95,7 +95,7 @@ static void get_weak_auth(USER& user, char* buf) {
|
|||
sprintf(buf, "%d_%s", user.id, out);
|
||||
}
|
||||
|
||||
static void send_error_message(SCHEDULER_REPLY& reply, char* msg, int delay) {
|
||||
static void send_error_message(SCHEDULER_REPLY& reply, const char* msg, int delay) {
|
||||
USER_MESSAGE um(msg, "low");
|
||||
reply.insert_message(um);
|
||||
reply.set_delay(delay);
|
||||
|
@ -189,7 +189,7 @@ static void mark_results_over(DB_HOST& host) {
|
|||
);
|
||||
while (!result.enumerate(buf)) {
|
||||
sprintf(buf2,
|
||||
"server_state=%d, outcome=%d, received_time = %d",
|
||||
"server_state=%d, outcome=%d, received_time = %ld",
|
||||
RESULT_SERVER_STATE_OVER,
|
||||
RESULT_OUTCOME_CLIENT_DETACHED,
|
||||
time(0)
|
||||
|
@ -999,8 +999,8 @@ bool unacceptable_os(
|
|||
unsigned int i;
|
||||
char buf[1024];
|
||||
|
||||
for (i=0; i<config.ban_os.size(); i++) {
|
||||
regex_t& re = config.ban_os[i];
|
||||
for (i=0; i<config.ban_os->size(); i++) {
|
||||
regex_t& re = (*config.ban_os)[i];
|
||||
strcpy(buf, sreq.host.os_name);
|
||||
strcat(buf, "\t");
|
||||
strcat(buf, sreq.host.os_version);
|
||||
|
@ -1027,8 +1027,8 @@ bool unacceptable_cpu(
|
|||
unsigned int i;
|
||||
char buf[1024];
|
||||
|
||||
for (i=0; i<config.ban_cpu.size(); i++) {
|
||||
regex_t& re = config.ban_cpu[i];
|
||||
for (i=0; i<config.ban_cpu->size(); i++) {
|
||||
regex_t& re = (*config.ban_cpu)[i];
|
||||
strcpy(buf, sreq.host.p_vendor);
|
||||
strcat(buf, "\t");
|
||||
strcat(buf, sreq.host.p_model);
|
||||
|
|
|
@ -52,8 +52,6 @@ void scan_work_array(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
|
|||
DB_RESULT result;
|
||||
char buf[256];
|
||||
APP* app;
|
||||
APP_VERSION* avp;
|
||||
bool found;
|
||||
|
||||
lock_sema();
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ static int send_assigned_job(
|
|||
static bool first=true;
|
||||
static int seqno=0;
|
||||
static R_RSA_PRIVATE_KEY key;
|
||||
APP* app;
|
||||
BEST_APP_VERSION* bavp;
|
||||
|
||||
if (first) {
|
||||
|
@ -70,7 +69,7 @@ static int send_assigned_job(
|
|||
}
|
||||
|
||||
sprintf(rtfpath, "../%s", wu.result_template_file);
|
||||
sprintf(suffix, "%d_%d_%d", getpid(), time(0), seqno++);
|
||||
sprintf(suffix, "%d_%d_%d", getpid(), (int)time(0), seqno++);
|
||||
retval = create_result(wu, rtfpath, suffix, key, config, 0, 0);
|
||||
if (retval) {
|
||||
log_messages.printf(MSG_CRITICAL,
|
||||
|
@ -101,7 +100,7 @@ static int send_assigned_job(
|
|||
}
|
||||
log_messages.printf(MSG_DEBUG,
|
||||
"[WU#%d] [RESULT#%d] [HOST#%d] send assignment %d\n",
|
||||
wu.id, result_id, reply.host.id
|
||||
wu.id, result_id, reply.host.id, asg.id
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -50,10 +50,11 @@ int SCHED_CONFIG::parse(FILE* f) {
|
|||
int retval;
|
||||
regex_t re;
|
||||
|
||||
// Don't bother to initialize to zero since it's a global.
|
||||
// If this ever changes, need to initialize
|
||||
//
|
||||
mf.init_file(f);
|
||||
|
||||
memset(this, 0, sizeof(*this));
|
||||
ban_os = new vector<regex_t>;
|
||||
ban_cpu = new vector<regex_t>;
|
||||
max_wus_to_send = 10;
|
||||
default_disk_max_used_gb = 100.;
|
||||
default_disk_max_used_pct = 50.;
|
||||
|
@ -151,14 +152,14 @@ int SCHED_CONFIG::parse(FILE* f) {
|
|||
if (xp.parse_bool(tag, "no_darwin_6", no_darwin_6)) {
|
||||
if (no_darwin_6) {
|
||||
regcomp(&re, ".*Darwin.*\t.*(5\\.|6\\.).*", REG_EXTENDED|REG_NOSUB);
|
||||
ban_os.push_back(re);
|
||||
ban_os->push_back(re);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (xp.parse_bool(tag, "no_amd_k6", no_amd_k6)) {
|
||||
if (no_amd_k6) {
|
||||
regcomp(&re, ".*AMD.*\t.*Family 5 Model 8 Stepping 0.*", REG_EXTENDED|REG_NOSUB);
|
||||
ban_cpu.push_back(re);
|
||||
ban_cpu->push_back(re);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -172,7 +173,7 @@ int SCHED_CONFIG::parse(FILE* f) {
|
|||
if (retval) {
|
||||
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
||||
} else {
|
||||
ban_os.push_back(re);
|
||||
ban_os->push_back(re);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -181,7 +182,7 @@ int SCHED_CONFIG::parse(FILE* f) {
|
|||
if (retval) {
|
||||
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
||||
} else {
|
||||
ban_cpu.push_back(re);
|
||||
ban_cpu->push_back(re);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -233,7 +234,7 @@ int SCHED_CONFIG::download_path(const char* filename, char* path) {
|
|||
}
|
||||
|
||||
void get_project_dir(char* p, int len) {
|
||||
char* unused = getcwd(p, len);
|
||||
getcwd(p, len);
|
||||
char* q = strrchr(p, '/');
|
||||
if (q) *q = 0;
|
||||
}
|
||||
|
|
|
@ -118,8 +118,8 @@ public:
|
|||
bool request_time_stats_log;
|
||||
bool enable_assignment;
|
||||
int max_ncpus;
|
||||
vector<regex_t> ban_os;
|
||||
vector<regex_t> ban_cpu;
|
||||
vector<regex_t> *ban_os;
|
||||
vector<regex_t> *ban_cpu;
|
||||
bool matchmaker;
|
||||
int mm_min_slots;
|
||||
int mm_max_slots;
|
||||
|
|
|
@ -217,7 +217,7 @@ BEST_APP_VERSION* get_app_version(
|
|||
return bavp;
|
||||
}
|
||||
|
||||
static char* find_user_friendly_name(int appid) {
|
||||
static const char* find_user_friendly_name(int appid) {
|
||||
APP* app = ssp->lookup_app(appid);
|
||||
if (app) return app->user_friendly_name;
|
||||
return "deprecated application";
|
||||
|
@ -1028,7 +1028,7 @@ int add_result_to_reply(
|
|||
result.update_field(buf);
|
||||
|
||||
dbwu.id = wu.id;
|
||||
sprintf(buf, "transition_time=%d", time(0));
|
||||
sprintf(buf, "transition_time=%ld", time(0));
|
||||
dbwu.update_field(buf);
|
||||
|
||||
}
|
||||
|
@ -1039,7 +1039,7 @@ int add_result_to_reply(
|
|||
if (wu.target_nresults == 1 && app->target_nresults > 1 && !reply.wreq.trust) {
|
||||
DB_WORKUNIT dbwu;
|
||||
char buf[256];
|
||||
sprintf(buf, "target_nresults=%d and transition_time=%d",
|
||||
sprintf(buf, "target_nresults=%d and transition_time=%ld",
|
||||
app->target_nresults, time(0)
|
||||
);
|
||||
dbwu.id = wu.id;
|
||||
|
@ -1064,6 +1064,7 @@ int add_result_to_reply(
|
|||
static void explain_to_user(SCHEDULER_REPLY& reply) {
|
||||
char helpful[512];
|
||||
unsigned int i;
|
||||
int j;
|
||||
|
||||
// If work was sent from apps // the user did not select, explain
|
||||
//
|
||||
|
@ -1090,8 +1091,8 @@ static void explain_to_user(SCHEDULER_REPLY& reply) {
|
|||
|
||||
// Tell the user about applications they didn't qualify for
|
||||
//
|
||||
for (i=0; i<preferred_app_message_index; i++){
|
||||
reply.insert_message(reply.wreq.no_work_messages.at(i));
|
||||
for (j=0; j<preferred_app_message_index; j++){
|
||||
reply.insert_message(reply.wreq.no_work_messages.at(j));
|
||||
}
|
||||
USER_MESSAGE um1("You have selected to receive work from other applications if no work is available for the applications you selected", "high");
|
||||
reply.insert_message(um1);
|
||||
|
|
|
@ -119,7 +119,7 @@ int CLIENT_PLATFORM::parse(FILE* fin) {
|
|||
|
||||
void WORK_REQ::insert_no_work_message(USER_MESSAGE& um) {
|
||||
bool found = false;
|
||||
for (int i=0; i<no_work_messages.size(); i++) {
|
||||
for (unsigned int i=0; i<no_work_messages.size(); i++) {
|
||||
if (!strcmp(um.message.c_str(), no_work_messages.at(i).message.c_str())){
|
||||
found = true;
|
||||
break;
|
||||
|
@ -164,7 +164,7 @@ const char* SCHEDULER_REQUEST::parse(FILE* fin) {
|
|||
have_time_stats_log = false;
|
||||
client_cap_plan_class = false;
|
||||
|
||||
char* unused = fgets(buf, sizeof(buf), fin);
|
||||
fgets(buf, sizeof(buf), fin);
|
||||
if (!match_tag(buf, "<scheduler_request>")) return "no start tag";
|
||||
while (fgets(buf, sizeof(buf), fin)) {
|
||||
if (match_tag(buf, "</scheduler_request>")) return NULL;
|
||||
|
@ -883,7 +883,6 @@ int APP_VERSION::write(FILE* fout) {
|
|||
|
||||
int RESULT::write_to_client(FILE* fout) {
|
||||
char buf[BLOB_SIZE];
|
||||
unsigned int i;
|
||||
|
||||
strcpy(buf, xml_doc_in);
|
||||
char* p = strstr(buf, "</result>");
|
||||
|
|
|
@ -169,7 +169,7 @@ static int process_wu_template(
|
|||
char* tmplate,
|
||||
const char** infiles,
|
||||
int ninfiles,
|
||||
SCHED_CONFIG& config,
|
||||
SCHED_CONFIG& config_loc,
|
||||
const char* command_line,
|
||||
const char* additional_xml
|
||||
) {
|
||||
|
@ -217,8 +217,8 @@ static int process_wu_template(
|
|||
);
|
||||
} else {
|
||||
dir_hier_path(
|
||||
infiles[file_number], config.download_dir,
|
||||
config.uldl_dir_fanout, path, true
|
||||
infiles[file_number], config_loc.download_dir,
|
||||
config_loc.uldl_dir_fanout, path, true
|
||||
);
|
||||
|
||||
// if file isn't found in hierarchy,
|
||||
|
@ -226,26 +226,26 @@ static int process_wu_template(
|
|||
//
|
||||
if (!boinc_file_exists(path)) {
|
||||
sprintf(top_download_path,
|
||||
"%s/%s",config.download_dir,
|
||||
"%s/%s",config_loc.download_dir,
|
||||
infiles[file_number]
|
||||
);
|
||||
boinc_copy(top_download_path, path);
|
||||
}
|
||||
|
||||
if (!config.cache_md5_info || !got_md5_info(path, md5, &nbytes)) {
|
||||
if (!config_loc.cache_md5_info || !got_md5_info(path, md5, &nbytes)) {
|
||||
retval = md5_file(path, md5, nbytes);
|
||||
if (retval) {
|
||||
fprintf(stderr, "process_wu_template: md5_file %d\n", retval);
|
||||
return retval;
|
||||
}
|
||||
else if (config.cache_md5_info) {
|
||||
else if (config_loc.cache_md5_info) {
|
||||
write_md5_info(path, md5, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
dir_hier_url(
|
||||
infiles[file_number], config.download_url,
|
||||
config.uldl_dir_fanout, url
|
||||
infiles[file_number], config_loc.download_url,
|
||||
config_loc.uldl_dir_fanout, url
|
||||
);
|
||||
sprintf(buf,
|
||||
" <name>%s</name>\n"
|
||||
|
@ -403,7 +403,7 @@ int create_result_ti(
|
|||
char* result_template_filename,
|
||||
char* result_name_suffix,
|
||||
R_RSA_PRIVATE_KEY& key,
|
||||
SCHED_CONFIG& config,
|
||||
SCHED_CONFIG& config_loc,
|
||||
char* query_string,
|
||||
// if nonzero, write value list here; else do insert
|
||||
int priority_increase
|
||||
|
@ -422,7 +422,7 @@ int create_result_ti(
|
|||
result_template_filename,
|
||||
result_name_suffix,
|
||||
key,
|
||||
config,
|
||||
config_loc,
|
||||
query_string,
|
||||
priority_increase
|
||||
);
|
||||
|
@ -436,7 +436,7 @@ int create_result(
|
|||
char* result_template_filename,
|
||||
char* result_name_suffix,
|
||||
R_RSA_PRIVATE_KEY& key,
|
||||
SCHED_CONFIG& config,
|
||||
SCHED_CONFIG& config_loc,
|
||||
char* query_string,
|
||||
// if nonzero, write value list here; else do insert
|
||||
int priority_increase
|
||||
|
@ -463,10 +463,7 @@ int create_result(
|
|||
}
|
||||
|
||||
retval = process_result_template(
|
||||
result_template,
|
||||
key,
|
||||
base_outfile_name,
|
||||
config
|
||||
result_template, key, base_outfile_name, config_loc
|
||||
);
|
||||
if (retval) {
|
||||
fprintf(stderr, "process_result_template() error: %d\n", retval);
|
||||
|
@ -495,7 +492,7 @@ int create_result(
|
|||
// if using locality scheduling, advertise data file
|
||||
// associated with this newly-created result
|
||||
//
|
||||
if (config.locality_scheduling) {
|
||||
if (config_loc.locality_scheduling) {
|
||||
char datafilename[512];
|
||||
char *last=strstr(result.name, "__");
|
||||
if (result.name<last && last<(result.name+255)) {
|
||||
|
@ -512,13 +509,13 @@ int create_result(
|
|||
|
||||
// make sure a WU's input files are actually there
|
||||
//
|
||||
int check_files(char** infiles, int ninfiles, SCHED_CONFIG& config) {
|
||||
int check_files(char** infiles, int ninfiles, SCHED_CONFIG& config_loc) {
|
||||
int i;
|
||||
char path[256];
|
||||
|
||||
for (i=0; i<ninfiles; i++) {
|
||||
dir_hier_path(
|
||||
infiles[i], config.download_dir, config.uldl_dir_fanout, path
|
||||
infiles[i], config_loc.download_dir, config_loc.uldl_dir_fanout, path
|
||||
);
|
||||
if (!boinc_file_exists(path)) {
|
||||
return 1;
|
||||
|
@ -535,7 +532,7 @@ int create_work(
|
|||
const char* result_template_filepath,
|
||||
const char** infiles,
|
||||
int ninfiles,
|
||||
SCHED_CONFIG& config,
|
||||
SCHED_CONFIG& config_loc,
|
||||
const char* command_line,
|
||||
const char* additional_xml
|
||||
) {
|
||||
|
@ -544,7 +541,7 @@ int create_work(
|
|||
char wu_template[BLOB_SIZE];
|
||||
|
||||
#if 0
|
||||
retval = check_files(infiles, ninfiles, config);
|
||||
retval = check_files(infiles, ninfiles, config_loc);
|
||||
if (retval) {
|
||||
fprintf(stderr, "Missing input file: %s\n", infiles[0]);
|
||||
return -1;
|
||||
|
@ -554,7 +551,7 @@ int create_work(
|
|||
strcpy(wu_template, _wu_template);
|
||||
wu.create_time = time(0);
|
||||
retval = process_wu_template(
|
||||
wu, wu_template, infiles, ninfiles, config, command_line, additional_xml
|
||||
wu, wu_template, infiles, ninfiles, config_loc, command_line, additional_xml
|
||||
);
|
||||
if (retval) {
|
||||
fprintf(stderr, "process_wu_template: %d\n", retval);
|
||||
|
|
|
@ -33,7 +33,7 @@ extern int process_result_template(
|
|||
char* result_template,
|
||||
R_RSA_PRIVATE_KEY& key,
|
||||
char* base_filename,
|
||||
SCHED_CONFIG& config
|
||||
SCHED_CONFIG&
|
||||
);
|
||||
|
||||
extern int read_file(FILE*, char* buf);
|
||||
|
|
|
@ -108,7 +108,7 @@ int process_result_template(
|
|||
char* result_template,
|
||||
R_RSA_PRIVATE_KEY& key,
|
||||
char* base_filename,
|
||||
SCHED_CONFIG& config
|
||||
SCHED_CONFIG& config_loc
|
||||
) {
|
||||
char* p,*q;
|
||||
char temp[BLOB_SIZE], buf[256];
|
||||
|
@ -132,13 +132,13 @@ int process_result_template(
|
|||
p = strstr(result_template, UPLOAD_URL_MACRO);
|
||||
if (p) {
|
||||
strcpy(temp, p+strlen(UPLOAD_URL_MACRO));
|
||||
strcpy(p, config.upload_url);
|
||||
strcpy(p, config_loc.upload_url);
|
||||
strcat(p, temp);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!config.dont_generate_upload_certificates) {
|
||||
if (!config_loc.dont_generate_upload_certificates) {
|
||||
retval = add_signatures(result_template, key);
|
||||
if (retval) return retval;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue