- client: change --detach_phase_two (??) to --detach_console

- eliminate compiler warnings (e.g. shadowed vars)
    in various places, mostly in client


svn path=/trunk/boinc/; revision=23710
This commit is contained in:
David Anderson 2011-06-12 20:58:43 +00:00
parent bdb01035d6
commit 94e8c48220
31 changed files with 1200 additions and 1215 deletions

View File

@ -425,7 +425,7 @@ int boinc_init_options(BOINC_OPTIONS* opt) {
// original process - master
//
options.send_status_msgs = false;
int retval = boinc_init_options_general(options);
retval = boinc_init_options_general(options);
if (retval) {
kill(child_pid, SIGKILL);
return retval;
@ -454,10 +454,10 @@ int boinc_init_options(BOINC_OPTIONS* opt) {
}
int boinc_init_parallel() {
BOINC_OPTIONS options;
boinc_options_defaults(options);
options.multi_thread = true;
return boinc_init_options(&options);
BOINC_OPTIONS _options;
boinc_options_defaults(_options);
_options.multi_thread = true;
return boinc_init_options(&_options);
}
int boinc_init_options_general(BOINC_OPTIONS& opt) {

View File

@ -216,7 +216,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;
@ -267,7 +267,7 @@ int main(int argc, char **argv) {
//
if (cpu_time) {
double start = dtime();
for (int i=0; ; i++) {
for (i=0; ; i++) {
double e = dtime()-start;
if (e > cpu_time) break;
fd = .5 + .5*(e/cpu_time);

View File

@ -3474,3 +3474,19 @@ David 10 Jun 2011
client/
client_types.cpp
David 12 Jun 2011
- client: change --detach_phase_two (??) to --detach_console
- eliminate compiler warnings (e.g. shadowed vars)
in various places, mostly in client
sched/
sched_main.cpp
lib/
cc_config.cpp
samples/
many.cpp
client/
many.cpp
api/
boinc_api.cpp

View File

@ -580,8 +580,8 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
pp->abort_not_started();
}
}
for (int i=0; i<MAX_RSC; i++) {
pp->no_rsc_ams[i] = acct.no_rsc[i];
for (int j=0; j<MAX_RSC; j++) {
pp->no_rsc_ams[j] = acct.no_rsc[j];
}
}
} else {
@ -597,8 +597,8 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
);
pp = gstate.lookup_project(acct.url.c_str());
if (pp) {
for (int i=0; i<MAX_RSC; i++) {
pp->no_rsc_ams[i] = acct.no_rsc[i];
for (int j=0; j<MAX_RSC; j++) {
pp->no_rsc_ams[j] = acct.no_rsc[j];
}
if (acct.dont_request_more_work.present) {
pp->dont_request_more_work = acct.dont_request_more_work.value;

View File

@ -106,7 +106,7 @@ int GET_PROJECT_CONFIG_OP::do_rpc(string master_url) {
);
retval = gui_http->do_rpc(
this, (char*)url.c_str(), GET_PROJECT_CONFIG_FILENAME, false
this, url.c_str(), GET_PROJECT_CONFIG_FILENAME, false
);
if (retval) {
error_num = retval;
@ -143,7 +143,7 @@ int LOOKUP_ACCOUNT_OP::do_rpc(ACCOUNT_IN& ai) {
url += parameter;
retval = gui_http->do_rpc(
this, (char*)url.c_str(), LOOKUP_ACCOUNT_FILENAME, false
this, url.c_str(), LOOKUP_ACCOUNT_FILENAME, false
);
if (retval) {
error_num = retval;
@ -191,7 +191,7 @@ int CREATE_ACCOUNT_OP::do_rpc(ACCOUNT_IN& ai) {
url += parameter;
}
retval = gui_http->do_rpc(
this, (char*)url.c_str(), CREATE_ACCOUNT_FILENAME, false
this, url.c_str(), CREATE_ACCOUNT_FILENAME, false
);
if (retval) {
error_num = retval;

View File

@ -906,9 +906,9 @@ int ACTIVE_TASK::start(bool first_time) {
#endif
#if defined (HAVE_SCHED_SETSCHEDULER) && defined(SCHED_BATCH) && defined (__linux__)
if (!high_priority) {
struct sched_param p;
p.sched_priority = 0;
if (sched_setscheduler(0, SCHED_BATCH, &p)) {
struct sched_param sp;
sp.sched_priority = 0;
if (sched_setscheduler(0, SCHED_BATCH, &sp)) {
perror("sched_setscheduler");
}
}

View File

@ -1750,8 +1750,8 @@ int CLIENT_STATE::reset_project(PROJECT* project, bool detaching) {
project->ams_resource_share = -1;
project->min_rpc_time = 0;
project->pwf.reset(project);
for (int i=0; i<coprocs.n_rsc; i++) {
project->rsc_pwf[i].reset();
for (int j=0; j<coprocs.n_rsc; j++) {
project->rsc_pwf[j].reset();
}
write_state_file();
return 0;

View File

@ -521,8 +521,6 @@ struct APP_VERSION {
double avg_ncpus;
double max_ncpus;
GPU_USAGE gpu_usage; // can only use 1 GPUtype
//double ncudas;
//double natis; // remove
double gpu_ram;
double flops;
char cmdline[256];
@ -557,8 +555,8 @@ struct APP_VERSION {
void get_file_errors(std::string&);
void clear_errors();
int api_major_version();
inline bool uses_coproc(int rsc_type) {
return (gpu_usage.rsc_type == rsc_type);
inline bool uses_coproc(int rt) {
return (gpu_usage.rsc_type == rt);
}
inline int rsc_type() {
return gpu_usage.rsc_type;

View File

@ -683,7 +683,7 @@ void COPROC_NVIDIA::get(
vector<string>& warnings,
vector<int>& ignore_devs
) {
int count, retval;
int cuda_ndevs, retval;
char buf[256];
#ifdef _WIN32
@ -803,7 +803,6 @@ void COPROC_NVIDIA::get(
return;
}
int cuda_version;
retval = (*__cuDriverGetVersion)(&cuda_version);
if (retval) {
sprintf(buf, "cuDriverGetVersion() returned %d", retval);
@ -812,20 +811,20 @@ void COPROC_NVIDIA::get(
}
vector<COPROC_NVIDIA> gpus;
retval = (*__cuDeviceGetCount)(&count);
retval = (*__cuDeviceGetCount)(&cuda_ndevs);
if (retval) {
sprintf(buf, "cuDeviceGetCount() returned %d", retval);
warnings.push_back(buf);
return;
}
sprintf(buf, "NVIDIA library reports %d GPU%s", count, (count==1)?"":"s");
sprintf(buf, "NVIDIA library reports %d GPU%s", cuda_ndevs, (cuda_ndevs==1)?"":"s");
warnings.push_back(buf);
int j;
unsigned int i;
COPROC_NVIDIA cc;
string s;
for (j=0; j<count; j++) {
for (j=0; j<cuda_ndevs; j++) {
memset(&cc.prop, 0, sizeof(cc.prop));
int device;
retval = (*__cuDeviceGet)(&device, j);
@ -881,40 +880,35 @@ void COPROC_NVIDIA::get(
// identify the most capable non-ignored instance
//
COPROC_NVIDIA best;
bool first = true;
for (i=0; i<gpus.size(); i++) {
if (in_vector(gpus[i].device_num, ignore_devs)) continue;
if (first) {
best = gpus[i];
*this = gpus[i];
first = false;
} else if (nvidia_compare(gpus[i], best, false) > 0) {
best = gpus[i];
} else if (nvidia_compare(gpus[i], *this, false) > 0) {
*this = gpus[i];
}
}
// see which other instances are equivalent,
// and set the "count" and "device_nums" fields
//
best.count = 0;
count = 0;
for (i=0; i<gpus.size(); i++) {
char buf2[256];
gpus[i].description(buf);
if (in_vector(gpus[i].device_num, ignore_devs)) {
sprintf(buf2, "NVIDIA GPU %d (ignored by config): %s", gpus[i].device_num, buf);
} else if (use_all || !nvidia_compare(gpus[i], best, true)) {
best.device_nums[best.count] = gpus[i].device_num;
best.count++;
} else if (use_all || !nvidia_compare(gpus[i], *this, true)) {
device_nums[count] = gpus[i].device_num;
count++;
sprintf(buf2, "NVIDIA GPU %d: %s", gpus[i].device_num, buf);
} else {
sprintf(buf2, "NVIDIA GPU %d (not used): %s", gpus[i].device_num, buf);
}
descs.push_back(string(buf2));
}
if (best.count) {
*this = best;
}
}
// fake a NVIDIA GPU (for debugging)
@ -1143,13 +1137,8 @@ void COPROC_ATI::get(
) {
CALuint numDevices, cal_major, cal_minor, cal_imp;
CALdevice device;
CALdeviceinfo info;
CALdeviceattribs attribs;
char buf[256];
bool amdrt_detected = false;
bool atirt_detected = false;
int retval;
unsigned int i;
attribs.struct_size = sizeof(CALdeviceattribs);
device = 0;
@ -1386,37 +1375,33 @@ void COPROC_ATI::get(
return;
}
COPROC_ATI best;
bool first = true;
unsigned int i;
for (i=0; i<gpus.size(); i++) {
if (in_vector(gpus[i].device_num, ignore_devs)) continue;
if (first) {
best = gpus[i];
*this = gpus[i];
first = false;
} else if (ati_compare(gpus[i], best, false) > 0) {
best = gpus[i];
} else if (ati_compare(gpus[i], *this, false) > 0) {
*this = gpus[i];
}
}
best.count = 0;
count = 0;
for (i=0; i<gpus.size(); i++) {
char buf[256], buf2[256];
char buf2[256];
gpus[i].description(buf);
if (in_vector(gpus[i].device_num, ignore_devs)) {
sprintf(buf2, "ATI GPU %d (ignored by config): %s", gpus[i].device_num, buf);
} else if (use_all || !ati_compare(gpus[i], best, true)) {
best.device_nums[best.count] = gpus[i].device_num;
best.count++;
} else if (use_all || !ati_compare(gpus[i], *this, true)) {
device_nums[count] = gpus[i].device_num;
count++;
sprintf(buf2, "ATI GPU %d: %s", gpus[i].device_num, buf);
} else {
sprintf(buf2, "ATI GPU %d: (not used) %s", gpus[i].device_num, buf);
}
descs.push_back(string(buf2));
}
if (best.count) {
*this = best;
}
}
void COPROC_ATI::fake(double ram, int n) {

View File

@ -667,9 +667,9 @@ void CLIENT_STATE::adjust_debts() {
if (use_rec) {
update_rec();
} else {
for (int i=0; i<coprocs.n_rsc; i++) {
rsc_work_fetch[i].update_long_term_debts();
rsc_work_fetch[i].update_short_term_debts();
for (int j=0; j<coprocs.n_rsc; j++) {
rsc_work_fetch[j].update_long_term_debts();
rsc_work_fetch[j].update_short_term_debts();
}
}

View File

@ -54,7 +54,7 @@ static void print_options(char* prog) {
" --attach_project <URL> <key> attach to a project\n"
" --check_all_logins for idle detection, check remote logins too\n"
" --daemon run as daemon (Unix)\n"
" --detach detach from console (Windows)\n"
" --detach_console detach from console (Windows)\n"
" --detach_project <URL> detach from a project\n"
" --dir <path> use given dir as BOINC home\n"
" --exit_after_app_start N exit N seconds after an app starts\n"
@ -136,7 +136,7 @@ void CLIENT_STATE::parse_cmdline(int argc, char** argv) {
check_all_logins = true;
} else if (ARG(daemon)) {
executing_as_daemon = true;
} else if (ARG(detach_phase_two)) {
} else if (ARG(detach_console)) {
detach_console = true;
} else if (ARG(detach_project)) {
if (i == argc-1) show_options = true;

View File

@ -649,7 +649,7 @@ int RSS_FEED::parse_items(XML_PARSER& xp, int& nitems) {
if (!strcmp(tag, "item")) {
NOTICE n;
ntotal++;
int retval = n.parse_rss(xp);
retval = n.parse_rss(xp);
if (retval) {
nerror++;
} else if (n.create_time < gstate.now - 30*86400) {

View File

@ -73,7 +73,6 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) {
MIOFILE mf;
unsigned int i;
RESULT* rp;
int retval;
double disk_total, disk_project;
get_sched_request_filename(*p, buf, sizeof(buf));
@ -205,8 +204,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) {
//
host_info.get_host_info();
set_ncpus();
retval = host_info.write(mf, !config.suppress_net_info, false);
//if (retval) return retval;
host_info.write(mf, !config.suppress_net_info, false);
// get and write disk usage
//
@ -484,7 +482,7 @@ int CLIENT_STATE::handle_scheduler_reply(PROJECT* project, char* scheduler_url)
int retval;
unsigned int i;
bool signature_valid, update_global_prefs=false, update_project_prefs=false;
char buf[256], filename[256];
char buf[1024], filename[256];
std::string old_gui_urls = project->gui_urls;
PROJECT* p2;
vector<RESULT*>new_results;
@ -571,7 +569,6 @@ int CLIENT_STATE::handle_scheduler_reply(PROJECT* project, char* scheduler_url)
for (i=0; i<sr.messages.size(); i++) {
USER_MESSAGE& um = sr.messages[i];
int prio = (!strcmp(um.priority.c_str(), "notice"))?MSG_SCHEDULER_ALERT:MSG_INFO;
char buf[1024];
string_substitute(um.message.c_str(), buf, sizeof(buf), "%", "%%");
msg_printf(project, prio, buf);
}
@ -886,10 +883,10 @@ int CLIENT_STATE::handle_scheduler_reply(PROJECT* project, char* scheduler_url)
if (log_flags.sched_op_debug) {
if (sr.results.size()) {
for (int i=0; i<coprocs.n_rsc; i++) {
for (int j=0; j<coprocs.n_rsc; j++) {
msg_printf(project, MSG_INFO,
"[sched_op] estimated total %s task duration: %.0f seconds",
rsc_name(i), est_rsc_duration[i]
rsc_name(j), est_rsc_duration[j]
);
}
}

View File

@ -31,7 +31,7 @@ int GET_CURRENT_VERSION_OP::do_rpc() {
int retval;
retval = gui_http->do_rpc(
this, (char*)config.client_version_check_url.c_str(),
this, config.client_version_check_url.c_str(),
GET_CURRENT_VERSION_FILENAME,
true
);

View File

@ -31,7 +31,7 @@
#include "gui_http.h"
int GUI_HTTP::do_rpc(
GUI_HTTP_OP* op, char* url, const char* output_file, bool is_bkgd
GUI_HTTP_OP* op, const char* url, const char* output_file, bool is_bkgd
) {
int retval;

View File

@ -36,7 +36,7 @@ struct GUI_HTTP {
GUI_HTTP(): gui_http_state(GUI_HTTP_STATE_IDLE) {}
int do_rpc(
struct GUI_HTTP_OP*, char* url, const char* output_file,
struct GUI_HTTP_OP*, const char* url, const char* output_file,
bool is_background
);
int do_rpc_post(

View File

@ -390,7 +390,6 @@ int HTTP_OP::libcurl_exec(
const char* url, const char* in, const char* out, double offset, bool bPost
) {
CURLMcode curlMErr;
CURLcode curlErr;
char strTmp[128];
static int outfile_seqno=0;
@ -421,10 +420,9 @@ int HTTP_OP::libcurl_exec(
}
// the following seems to be a no-op
//curlErr = curl_easy_setopt(curlEasy, CURLOPT_ERRORBUFFER, error_msg);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_URL, m_url);
// curl_easy_setopt(curlEasy, CURLOPT_ERRORBUFFER, error_msg);
curl_easy_setopt(curlEasy, CURLOPT_URL, m_url);
// This option determines whether curl verifies that the server
// claims to be who you want it to be.
@ -446,7 +444,7 @@ int HTTP_OP::libcurl_exec(
// the server claims. The server could be lying.
// To control lying, see CURLOPT_SSL_VERIFYPEER.
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_SSL_VERIFYHOST, 2L);
curl_easy_setopt(curlEasy, CURLOPT_SSL_VERIFYHOST, 2L);
// the following sets "tough" certificate checking
// (i.e. whether self-signed is OK)
@ -454,7 +452,7 @@ int HTTP_OP::libcurl_exec(
// (cert not 3rd party trusted)
// if non-zero below, you need a valid 3rd party CA (i.e. Verisign, Thawte)
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curlEasy, CURLOPT_SSL_VERIFYPEER, 1L);
// if the above is nonzero, you need the following:
//
@ -492,7 +490,7 @@ int HTTP_OP::libcurl_exec(
// call this only if a local copy of ca-bundle.crt exists;
// otherwise, let's hope that it exists in the default place
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_CAINFO, m_curl_ca_bundle_location);
curl_easy_setopt(curlEasy, CURLOPT_CAINFO, m_curl_ca_bundle_location);
if (log_flags.http_debug) {
msg_printf(
0,
@ -506,38 +504,38 @@ int HTTP_OP::libcurl_exec(
// call this only if a local copy of ca-bundle.crt exists;
// otherwise, let's hope that it exists in the default place
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_CAINFO, CA_BUNDLE_FILENAME);
curl_easy_setopt(curlEasy, CURLOPT_CAINFO, CA_BUNDLE_FILENAME);
}
#endif
// set the user agent as this boinc client & version
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_USERAGENT, g_user_agent_string);
curl_easy_setopt(curlEasy, CURLOPT_USERAGENT, g_user_agent_string);
// bypass any signal handlers that curl may want to install
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt(curlEasy, CURLOPT_NOSIGNAL, 1L);
// bypass progress meter
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curlEasy, CURLOPT_NOPROGRESS, 1L);
// setup timeouts
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_TIMEOUT, 0L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_LOW_SPEED_LIMIT, config.http_transfer_timeout_bps);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_LOW_SPEED_TIME, config.http_transfer_timeout);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_CONNECTTIMEOUT, 120L);
curl_easy_setopt(curlEasy, CURLOPT_TIMEOUT, 0L);
curl_easy_setopt(curlEasy, CURLOPT_LOW_SPEED_LIMIT, config.http_transfer_timeout_bps);
curl_easy_setopt(curlEasy, CURLOPT_LOW_SPEED_TIME, config.http_transfer_timeout);
curl_easy_setopt(curlEasy, CURLOPT_CONNECTTIMEOUT, 120L);
// force curl to use HTTP/1.0 if config specifies it
// (curl uses 1.1 by default)
//
if (config.http_1_0 || (config.force_auth == "ntlm")) {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_easy_setopt(curlEasy, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
}
curlErr = curl_easy_setopt(curlEasy, CURLOPT_MAXREDIRS, 50L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_AUTOREFERER, 1L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_FOLLOWLOCATION, 1L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POST301, 1L);
curl_easy_setopt(curlEasy, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(curlEasy, CURLOPT_AUTOREFERER, 1L);
curl_easy_setopt(curlEasy, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curlEasy, CURLOPT_POST301, 1L);
// if we tell Curl to accept any encoding (e.g. deflate)
// it seems to accept them all, which screws up projects that
@ -545,7 +543,7 @@ int HTTP_OP::libcurl_exec(
// So, detect this and don't accept any encoding in that case
//
if (!out || !ends_with(std::string(out), std::string(".gz"))) {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_ENCODING, "");
curl_easy_setopt(curlEasy, CURLOPT_ENCODING, "");
}
// setup any proxy they may need
@ -584,11 +582,11 @@ int HTTP_OP::libcurl_exec(
// we can make the libcurl_write "fancier" in the future,
// for now it just fwrite's to the file request, which is sufficient
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_WRITEFUNCTION, libcurl_write);
curl_easy_setopt(curlEasy, CURLOPT_WRITEFUNCTION, libcurl_write);
// note that in my lib_write I'm sending in a pointer
// to this instance of HTTP_OP
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_WRITEDATA, this);
curl_easy_setopt(curlEasy, CURLOPT_WRITEDATA, this);
}
if (bPost) {
@ -605,7 +603,7 @@ int HTTP_OP::libcurl_exec(
}
if (pcurlList) { // send custom headers if required
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
}
// set the data file info to read for the PUT/POST
@ -614,11 +612,11 @@ int HTTP_OP::libcurl_exec(
#if 0
// HTTP PUT method
curl_off_t fs = (curl_off_t) content_length;
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDS, NULL);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_INFILESIZE, content_length);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READDATA, fileIn);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_INFILESIZE_LARGE, fs);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PUT, 1L);
curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDS, NULL);
curl_easy_setopt(curlEasy, CURLOPT_INFILESIZE, content_length);
curl_easy_setopt(curlEasy, CURLOPT_READDATA, fileIn);
curl_easy_setopt(curlEasy, CURLOPT_INFILESIZE_LARGE, fs);
curl_easy_setopt(curlEasy, CURLOPT_PUT, 1L);
#endif
// HTTP POST method
@ -631,14 +629,16 @@ int HTTP_OP::libcurl_exec(
//
pcurlFormStart = pcurlFormEnd = NULL;
curl_formadd(&pcurlFormStart, &pcurlFormEnd,
CURLFORM_FILECONTENT, infile,
CURLFORM_CONTENTSLENGTH, content_length,
CURLFORM_CONTENTTYPE, g_content_type,
CURLFORM_END);
CURLFORM_FILECONTENT, infile,
CURLFORM_CONTENTSLENGTH, content_length,
CURLFORM_CONTENTTYPE, g_content_type,
CURLFORM_END
);
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "logotype-image",
CURLFORM_FILECONTENT, "curl.png", CURLFORM_END);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPPOST, pcurlFormStart);
CURLFORM_COPYNAME, "logotype-image",
CURLFORM_FILECONTENT, "curl.png", CURLFORM_END
);
curl_easy_setopt(curlEasy, CURLOPT_HTTPPOST, pcurlFormStart);
#endif
curl_off_t fs = (curl_off_t) content_length;
@ -649,19 +649,19 @@ int HTTP_OP::libcurl_exec(
// we can make the libcurl_read "fancier" in the future,
// for now it just fwrite's to the file request, which is sufficient
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDS, NULL);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDSIZE_LARGE, fs);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READFUNCTION, libcurl_read);
curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDS, NULL);
curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDSIZE_LARGE, fs);
curl_easy_setopt(curlEasy, CURLOPT_READFUNCTION, libcurl_read);
// in my lib_write I'm sending in a pointer to this instance of HTTP_OP
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READDATA, this);
curl_easy_setopt(curlEasy, CURLOPT_READDATA, this);
// callback function to rewind input file
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_IOCTLFUNCTION, libcurl_ioctl);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_IOCTLDATA, this);
curl_easy_setopt(curlEasy, CURLOPT_IOCTLFUNCTION, libcurl_ioctl);
curl_easy_setopt(curlEasy, CURLOPT_IOCTLDATA, this);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POST, 1L);
curl_easy_setopt(curlEasy, CURLOPT_POST, 1L);
} else { // GET
want_upload = false;
want_download = true;
@ -669,20 +669,20 @@ int HTTP_OP::libcurl_exec(
// now write the header, pcurlList gets freed in net_xfer_curl
//
if (pcurlList) { // send custom headers if required
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
}
// setup the GET!
//
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPGET, 1L);
curl_easy_setopt(curlEasy, CURLOPT_HTTPGET, 1L);
}
// turn on debug info if tracing enabled
//
if (log_flags.http_debug) {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_DEBUGFUNCTION, libcurl_debugfunction);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_DEBUGDATA, this );
curlErr = curl_easy_setopt(curlEasy, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curlEasy, CURLOPT_DEBUGFUNCTION, libcurl_debugfunction);
curl_easy_setopt(curlEasy, CURLOPT_DEBUGDATA, this );
curl_easy_setopt(curlEasy, CURLOPT_VERBOSE, 1L);
}
// last but not least, add this to the curl_multi
@ -748,7 +748,6 @@ int HTTP_OP_SET::nops() {
// CURLAUTH_GSSNEGOTIATE, CURLAUTH_NTLM, CURLAUTH_ANY, CURLAUTH_ANYSAFE
// CURLOPT_PROXYAUTH -- "or" | the above bitmasks -- only basic, digest, ntlm work
void HTTP_OP::setup_proxy_session(bool no_proxy) {
CURLcode curlErr;
// CMC Note: the string m_curl_user_credentials must remain in memory
// outside of this method (libcurl relies on it later when it makes
@ -757,7 +756,7 @@ void HTTP_OP::setup_proxy_session(bool no_proxy) {
strcpy(m_curl_user_credentials, "");
if (no_proxy) {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXY, "");
curl_easy_setopt(curlEasy, CURLOPT_PROXY, "");
return;
}
@ -771,41 +770,41 @@ void HTTP_OP::setup_proxy_session(bool no_proxy) {
}
// setup a basic http proxy
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.http_server_port);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.http_server_name);
curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.http_server_port);
curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.http_server_name);
if (pi.use_http_auth) {
if (config.force_auth == "basic") {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
} else if (config.force_auth == "digest") {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
} else if (config.force_auth == "gss-negotiate") {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_GSSNEGOTIATE);
curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_GSSNEGOTIATE);
} else if (config.force_auth == "ntlm") {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
} else {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
}
sprintf(m_curl_user_credentials, "%s:%s", pi.http_user_name, pi.http_user_passwd);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYUSERPWD, m_curl_user_credentials);
curl_easy_setopt(curlEasy, CURLOPT_PROXYUSERPWD, m_curl_user_credentials);
}
} else if (pi.use_socks_proxy) {
// CURL only supports SOCKS version 5
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.socks_server_port);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.socks_server_name);
curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.socks_server_port);
curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.socks_server_name);
// libcurl uses blocking sockets with socks proxy, so limit timeout.
// - imlemented with local patch to libcurl
curlErr = curl_easy_setopt(curlEasy, CURLOPT_CONNECTTIMEOUT, 20L);
curl_easy_setopt(curlEasy, CURLOPT_CONNECTTIMEOUT, 20L);
if (
strlen(pi.socks5_user_passwd) || strlen(pi.socks5_user_name)
) {
sprintf(m_curl_user_credentials, "%s:%s", pi.socks5_user_name, pi.socks5_user_passwd);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYUSERPWD, m_curl_user_credentials);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_ANY & ~CURLAUTH_NTLM);
curl_easy_setopt(curlEasy, CURLOPT_PROXYUSERPWD, m_curl_user_credentials);
curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_ANY & ~CURLAUTH_NTLM);
}
} else if (pi.have_autodetect_proxy_settings && strlen(pi.autodetect_server_name)) {
if (log_flags.proxy_debug) {
@ -817,16 +816,16 @@ void HTTP_OP::setup_proxy_session(bool no_proxy) {
switch(pi.autodetect_protocol) {
case URL_PROTOCOL_SOCKS:
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
break;
case URL_PROTOCOL_HTTP:
case URL_PROTOCOL_HTTPS:
default:
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
break;
}
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.autodetect_port);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.autodetect_server_name);
curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.autodetect_port);
curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.autodetect_server_name);
}
}
@ -886,8 +885,7 @@ void HTTP_OP::close_file() {
}
void HTTP_OP_SET::get_fdset(FDSET_GROUP& fg) {
CURLMcode curlMErr;
curlMErr = curl_multi_fdset(
curl_multi_fdset(
g_curlMulti, &fg.read_fds, &fg.write_fds, &fg.exc_fds, &fg.max_fd
);
}
@ -896,17 +894,16 @@ void HTTP_OP_SET::get_fdset(FDSET_GROUP& fg) {
// get the response code for this request
//
void HTTP_OP::handle_messages(CURLMsg *pcurlMsg) {
CURLcode curlErr;
int retval;
curlErr = curl_easy_getinfo(curlEasy,
curl_easy_getinfo(curlEasy,
CURLINFO_RESPONSE_CODE, &response
);
// CURLINFO_LONG+25 is a workaround for a bug in the gcc version
// included with Mac OS X 10.3.9
//
curlErr = curl_easy_getinfo(curlEasy,
curl_easy_getinfo(curlEasy,
(CURLINFO)(CURLINFO_LONG+25) /*CURLINFO_OS_ERRNO*/, &connect_error
);
@ -922,13 +919,9 @@ void HTTP_OP::handle_messages(CURLMsg *pcurlMsg) {
// (we don't use it)
//
double size_download, total_time, starttransfer_time;
curlErr = curl_easy_getinfo(curlEasy,
CURLINFO_SIZE_DOWNLOAD, &size_download
);
curlErr = curl_easy_getinfo(curlEasy,
CURLINFO_TOTAL_TIME, &total_time
);
curlErr = curl_easy_getinfo(curlEasy,
curl_easy_getinfo(curlEasy, CURLINFO_SIZE_DOWNLOAD, &size_download);
curl_easy_getinfo(curlEasy, CURLINFO_TOTAL_TIME, &total_time);
curl_easy_getinfo(curlEasy,
CURLINFO_STARTTRANSFER_TIME, &starttransfer_time
);
double dt = total_time - starttransfer_time;
@ -938,13 +931,9 @@ void HTTP_OP::handle_messages(CURLMsg *pcurlMsg) {
}
if (want_upload) {
double size_upload, total_time, starttransfer_time;
curlErr = curl_easy_getinfo(curlEasy,
CURLINFO_SIZE_UPLOAD, &size_upload
);
curlErr = curl_easy_getinfo(curlEasy,
CURLINFO_TOTAL_TIME, &total_time
);
curlErr = curl_easy_getinfo(curlEasy,
curl_easy_getinfo(curlEasy, CURLINFO_SIZE_UPLOAD, &size_upload);
curl_easy_getinfo(curlEasy, CURLINFO_TOTAL_TIME, &total_time);
curl_easy_getinfo(curlEasy,
CURLINFO_STARTTRANSFER_TIME, &starttransfer_time
);
double dt = total_time - starttransfer_time;

View File

@ -297,7 +297,7 @@ int CONFIG::parse_options_client(XML_PARSER& xp) {
if (xp.parse_bool(tag, "os_random_only", os_random_only)) continue;
#ifndef SIM
if (!strcmp(tag, "proxy_info")) {
int retval = config_proxy_info.parse_config(*xp.f);
retval = config_proxy_info.parse_config(*xp.f);
if (retval) return retval;
continue;
}

View File

@ -234,9 +234,7 @@ int LOOKUP_WEBSITE_OP::do_rpc(string& url) {
"Project communication failed: attempting access to reference site"
);
}
retval = gui_http->do_rpc(
this, (char*)url.c_str(), LOOKUP_WEBSITE_FILENAME, true
);
retval = gui_http->do_rpc(this, url.c_str(), LOOKUP_WEBSITE_FILENAME, true);
if (retval) {
error_num = retval;
net_status.need_physical_connection = true;

View File

@ -251,7 +251,7 @@ void CLIENT_STATE::rr_simulation() {
PROJECT* p, *pbest;
RESULT* rp, *rpbest;
RR_SIM_STATUS sim_status;
unsigned int i;
unsigned int u;
double ar = available_ram();
@ -265,8 +265,8 @@ void CLIENT_STATE::rr_simulation() {
);
}
for (i=0; i<projects.size(); i++) {
p = projects[i];
for (u=0; u<projects.size(); u++) {
p = projects[u];
if (p->non_cpu_intensive) continue;
p->rr_sim_status.clear();
}
@ -275,8 +275,8 @@ void CLIENT_STATE::rr_simulation() {
// and pick the ones that are initially running.
// NOTE: "results" is sorted by increasing arrival time
//
for (i=0; i<results.size(); i++) {
rp = results[i];
for (u=0; u<results.size(); u++) {
rp = results[u];
rp->rr_sim_misses_deadline = false;
if (!rp->nearly_runnable()) continue;
if (rp->some_download_stalled()) continue;
@ -331,8 +331,8 @@ void CLIENT_STATE::rr_simulation() {
// compute finish times and see which result finishes first
//
rpbest = NULL;
for (i=0; i<sim_status.active.size(); i++) {
rp = sim_status.active[i];
for (u=0; u<sim_status.active.size(); u++) {
rp = sim_status.active[u];
set_rrsim_flops(rp);
//rp->rrsim_finish_delay = rp->avp->temp_dcf*rp->rrsim_flops_left/rp->rrsim_flops;
rp->rrsim_finish_delay = rp->rrsim_flops_left/rp->rrsim_flops;
@ -430,7 +430,7 @@ void CLIENT_STATE::rr_simulation() {
while (1) {
if (rsc_work_fetch[rt].sim_nused >= coprocs.coprocs[rt].count) break;
if (!rsc_work_fetch[rt].pending.size()) break;
RESULT* rp = rsc_work_fetch[rt].pending[0];
rp = rsc_work_fetch[rt].pending[0];
rsc_work_fetch[rt].pending.erase(rsc_work_fetch[rt].pending.begin());
sim_status.activate(rp, sim_now-now);
pbest->rr_sim_status.activate(rp);
@ -438,7 +438,7 @@ void CLIENT_STATE::rr_simulation() {
} else {
while (1) {
if (pbest->rsc_pwf[0].sim_nused >= ncpus) break;
RESULT* rp = pbest->rr_sim_status.get_pending();
rp = pbest->rr_sim_status.get_pending();
if (!rp) break;
sim_status.activate(rp, sim_now-now);
pbest->rr_sim_status.activate(rp);

View File

@ -149,11 +149,11 @@ void TIME_STATS::get_log_after(double t, MIOFILE& mf) {
// so these get written to disk only when other activities
// cause this to happen. Maybe should change this.
//
void TIME_STATS::update(int suspend_reason, int gpu_suspend_reason) {
void TIME_STATS::update(int suspend_reason, int _gpu_suspend_reason) {
double dt, w1, w2;
bool is_active = !(suspend_reason & ~SUSPEND_REASON_CPU_THROTTLE);
bool is_gpu_active = is_active && !gpu_suspend_reason;
bool is_gpu_active = is_active && !_gpu_suspend_reason;
if (last_update == 0) {
// this is the first time this client has executed.
// Assume that everything is active

View File

@ -1066,7 +1066,6 @@ void WORK_FETCH::write_request(FILE* f, PROJECT* p) {
void WORK_FETCH::handle_reply(
PROJECT* p, SCHEDULER_REPLY*, vector<RESULT*> new_results
) {
unsigned int i;
bool got_rsc[MAX_RSC];
for (int i=0; i<coprocs.n_rsc; i++) {
got_rsc[i] = false;
@ -1089,7 +1088,7 @@ void WORK_FETCH::handle_reply(
// if we did get jobs, clear backoff on resource types
//
for (i=0; i<new_results.size(); i++) {
for (unsigned int i=0; i<new_results.size(); i++) {
RESULT* rp = new_results[i];
got_rsc[rp->avp->gpu_usage.rsc_type] = true;
}

View File

@ -336,7 +336,7 @@ int CONFIG::parse_options(XML_PARSER& xp) {
if (xp.parse_bool(tag, "os_random_only", os_random_only)) continue;
#ifndef SIM
if (!strcmp(tag, "proxy_info")) {
int retval = proxy_info.parse_config(*xp.f);
retval = proxy_info.parse_config(*xp.f);
if (retval) return retval;
continue;
}

View File

@ -5,6 +5,7 @@ BOINC_API_DIR = $(BOINC_DIR)/api
BOINC_LIB_DIR = $(BOINC_DIR)/lib
CXXFLAGS = -g \
-Wall -W -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common \
-DAPP_GRAPHICS \
-I$(BOINC_DIR) \
-I$(BOINC_LIB_DIR) \

View File

@ -216,7 +216,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;
@ -267,7 +267,7 @@ int main(int argc, char **argv) {
//
if (cpu_time) {
double start = dtime();
for (int i=0; ; i++) {
for (i=0; ; i++) {
double e = dtime()-start;
if (e > cpu_time) break;
fd = .5 + .5*(e/cpu_time);

View File

@ -6,6 +6,7 @@ BOINC_API_DIR = $(BOINC_DIR)/api
BOINC_LIB_DIR = $(BOINC_DIR)/lib
CXXFLAGS = -g \
-Wall -W -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common \
-I$(BOINC_DIR) \
-I$(BOINC_LIB_DIR) \
-I$(BOINC_API_DIR) \

File diff suppressed because it is too large Load Diff

View File

@ -1,216 +1,216 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2010 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// vboxwrapper.cpp
// vboxwrapper program - lets you use VirtualBox VMs with BOINC
//
// Handles:
// - suspend/resume/quit/abort
// - reporting CPU time
// - loss of heartbeat from core client
// - checkpointing
// (at the level of task; or potentially within task)
//
// See http://boinc.berkeley.edu/wrapper.php for details
// Contributor: Andrew J. Younge (ajy4490@umiacs.umd.edu)
// Contributor: Jie Wu <jiewu AT cern DOT ch>
// Contributor: Daniel Lombraña González <teleyinex AT gmail DOT com>
//
#ifdef _WIN32
#include "boinc_win.h"
#include "win_util.h"
#else
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <string>
#include <unistd.h>
#endif
#include "boinc_api.h"
#include "diagnostics.h"
#include "filesys.h"
#include "parse.h"
#include "str_util.h"
#include "str_replace.h"
#include "util.h"
#include "error_numbers.h"
#include "procinfo.h"
#include "vm.h"
#include "vbox.h"
#define JOB_FILENAME "vbox_job.xml"
#define CHECKPOINT_FILENAME "vbox_checkpoint.txt"
#define POLL_PERIOD 1.0
int parse_job_file() {
MIOFILE mf;
char tag[1024], buf[256], buf2[256];
bool is_tag;
boinc_resolve_filename(JOB_FILENAME, buf, 1024);
FILE* f = boinc_fopen(buf, "r");
if (!f) {
fprintf(stderr,
"%s can't open job file %s\n",
boinc_msg_prefix(buf2, sizeof(buf2)), buf
);
return ERR_FOPEN;
}
mf.init_file(f);
XML_PARSER xp(&mf);
if (!xp.parse_start("vbox_job_desc")) return ERR_XML_PARSE;
while (!xp.get(tag, sizeof(tag), is_tag)) {
if (!is_tag) {
fprintf(stderr,
"%s SCHED_CONFIG::parse(): unexpected text %s\n",
boinc_msg_prefix(buf2, sizeof(buf2)), tag
);
continue;
}
if (!strcmp(tag, "vbox_job_desc")) {
vm.parse(xp);
}
}
fclose(f);
return ERR_XML_PARSE;
}
void write_checkpoint(double cpu) {
boinc_begin_critical_section();
FILE* f = fopen(CHECKPOINT_FILENAME, "w");
if (!f) return;
fprintf(f, "%f\n", cpu);
fclose(f);
boinc_checkpoint_completed();
}
void read_checkpoint(double& cpu) {
double c;
cpu = 0;
FILE* f = fopen(CHECKPOINT_FILENAME, "r");
if (!f) return;
int n = fscanf(f, "%lf", &c);
fclose(f);
if (n != 1) return;
cpu = c;
}
int main(int argc, char** argv) {
BOINC_OPTIONS boinc_options;
BOINC_STATUS boinc_status;
double current_cpu_time = 0.0;
double checkpoint_cpu_time = 0.0;
bool is_running = false;
char buf[256];
int retval;
memset(&boinc_options, 0, sizeof(boinc_options));
boinc_options.main_program = true;
boinc_options.check_heartbeat = true;
boinc_options.handle_process_control = true;
boinc_init_options(&boinc_options);
fprintf(
stderr,
"%s vboxwrapper: starting\n",
boinc_msg_prefix(buf, sizeof(buf))
);
retval = parse_job_file();
if (retval) {
fprintf(
stderr,
"%s can't parse job file: %d\n",
boinc_msg_prefix(buf, sizeof(buf)),
retval
);
boinc_finish(retval);
}
read_checkpoint(checkpoint_cpu_time);
retval = vm.run();
if (retval) {
boinc_finish(retval);
}
while (1) {
vm.poll();
is_running = vm.is_running();
boinc_get_status(&boinc_status);
if (boinc_status.no_heartbeat || boinc_status.quit_request) {
vm.stop();
write_checkpoint(checkpoint_cpu_time);
boinc_temporary_exit(0);
}
if (boinc_status.abort_request) {
vm.cleanup();
write_checkpoint(checkpoint_cpu_time);
boinc_finish(EXIT_ABORTED_BY_CLIENT);
}
if (!is_running) {
vm.cleanup();
write_checkpoint(checkpoint_cpu_time);
boinc_finish(0);
}
if (boinc_status.suspended) {
if (!vm.suspended) {
vm.pause();
}
} else {
if (vm.suspended) {
vm.resume();
}
}
if (boinc_time_to_checkpoint()) {
boinc_checkpoint_completed();
checkpoint_cpu_time += current_cpu_time;
current_cpu_time = 0.0;
}
if (is_running) {
current_cpu_time += 1.0;
boinc_report_app_status(current_cpu_time, checkpoint_cpu_time, 0.0);
}
boinc_sleep(POLL_PERIOD);
}
return 0;
}
#ifdef _WIN32
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode) {
LPSTR command_line;
char* argv[100];
int argc;
command_line = GetCommandLine();
argc = parse_command_line(command_line, argv);
return main(argc, argv);
}
#endif
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2010 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// vboxwrapper.cpp
// vboxwrapper program - lets you use VirtualBox VMs with BOINC
//
// Handles:
// - suspend/resume/quit/abort
// - reporting CPU time
// - loss of heartbeat from core client
// - checkpointing
// (at the level of task; or potentially within task)
//
// See http://boinc.berkeley.edu/wrapper.php for details
// Contributor: Andrew J. Younge (ajy4490@umiacs.umd.edu)
// Contributor: Jie Wu <jiewu AT cern DOT ch>
// Contributor: Daniel Lombraña González <teleyinex AT gmail DOT com>
//
#ifdef _WIN32
#include "boinc_win.h"
#include "win_util.h"
#else
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <string>
#include <unistd.h>
#endif
#include "boinc_api.h"
#include "diagnostics.h"
#include "filesys.h"
#include "parse.h"
#include "str_util.h"
#include "str_replace.h"
#include "util.h"
#include "error_numbers.h"
#include "procinfo.h"
#include "vm.h"
#include "vbox.h"
#define JOB_FILENAME "vbox_job.xml"
#define CHECKPOINT_FILENAME "vbox_checkpoint.txt"
#define POLL_PERIOD 1.0
int parse_job_file() {
MIOFILE mf;
char tag[1024], buf[256], buf2[256];
bool is_tag;
boinc_resolve_filename(JOB_FILENAME, buf, 1024);
FILE* f = boinc_fopen(buf, "r");
if (!f) {
fprintf(stderr,
"%s can't open job file %s\n",
boinc_msg_prefix(buf2, sizeof(buf2)), buf
);
return ERR_FOPEN;
}
mf.init_file(f);
XML_PARSER xp(&mf);
if (!xp.parse_start("vbox_job_desc")) return ERR_XML_PARSE;
while (!xp.get(tag, sizeof(tag), is_tag)) {
if (!is_tag) {
fprintf(stderr,
"%s SCHED_CONFIG::parse(): unexpected text %s\n",
boinc_msg_prefix(buf2, sizeof(buf2)), tag
);
continue;
}
if (!strcmp(tag, "vbox_job_desc")) {
vm.parse(xp);
}
}
fclose(f);
return ERR_XML_PARSE;
}
void write_checkpoint(double cpu) {
boinc_begin_critical_section();
FILE* f = fopen(CHECKPOINT_FILENAME, "w");
if (!f) return;
fprintf(f, "%f\n", cpu);
fclose(f);
boinc_checkpoint_completed();
}
void read_checkpoint(double& cpu) {
double c;
cpu = 0;
FILE* f = fopen(CHECKPOINT_FILENAME, "r");
if (!f) return;
int n = fscanf(f, "%lf", &c);
fclose(f);
if (n != 1) return;
cpu = c;
}
int main() {
BOINC_OPTIONS boinc_options;
BOINC_STATUS boinc_status;
double current_cpu_time = 0.0;
double checkpoint_cpu_time = 0.0;
bool is_running = false;
char buf[256];
int retval;
memset(&boinc_options, 0, sizeof(boinc_options));
boinc_options.main_program = true;
boinc_options.check_heartbeat = true;
boinc_options.handle_process_control = true;
boinc_init_options(&boinc_options);
fprintf(
stderr,
"%s vboxwrapper: starting\n",
boinc_msg_prefix(buf, sizeof(buf))
);
retval = parse_job_file();
if (retval) {
fprintf(
stderr,
"%s can't parse job file: %d\n",
boinc_msg_prefix(buf, sizeof(buf)),
retval
);
boinc_finish(retval);
}
read_checkpoint(checkpoint_cpu_time);
retval = vm.run();
if (retval) {
boinc_finish(retval);
}
while (1) {
vm.poll();
is_running = vm.is_running();
boinc_get_status(&boinc_status);
if (boinc_status.no_heartbeat || boinc_status.quit_request) {
vm.stop();
write_checkpoint(checkpoint_cpu_time);
boinc_temporary_exit(0);
}
if (boinc_status.abort_request) {
vm.cleanup();
write_checkpoint(checkpoint_cpu_time);
boinc_finish(EXIT_ABORTED_BY_CLIENT);
}
if (!is_running) {
vm.cleanup();
write_checkpoint(checkpoint_cpu_time);
boinc_finish(0);
}
if (boinc_status.suspended) {
if (!vm.suspended) {
vm.pause();
}
} else {
if (vm.suspended) {
vm.resume();
}
}
if (boinc_time_to_checkpoint()) {
boinc_checkpoint_completed();
checkpoint_cpu_time += current_cpu_time;
current_cpu_time = 0.0;
}
if (is_running) {
current_cpu_time += 1.0;
boinc_report_app_status(current_cpu_time, checkpoint_cpu_time, 0.0);
}
boinc_sleep(POLL_PERIOD);
}
return 0;
}
#ifdef _WIN32
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode) {
LPSTR command_line;
char* argv[100];
int argc;
command_line = GetCommandLine();
argc = parse_command_line(command_line, argv);
return main(argc, argv);
}
#endif

View File

@ -6,6 +6,7 @@ BOINC_API_DIR = $(BOINC_DIR)/api
BOINC_LIB_DIR = $(BOINC_DIR)/lib
CXXFLAGS = -g \
-Wall -W -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common \
-I$(BOINC_DIR) \
-I$(BOINC_LIB_DIR) \
-I$(BOINC_API_DIR) \

View File

@ -472,7 +472,6 @@ int TASK::run(int argct, char** argvt) {
SetThreadPriority(thread_handle, THREAD_PRIORITY_IDLE);
#else
int retval, argc;
char progname[256];
char* argv[256];
char arglist[4096];
FILE* stdout_file;
@ -515,12 +514,11 @@ int TASK::run(int argct, char** argvt) {
argc = parse_command_line(arglist, argv+1);
setpriority(PRIO_PROCESS, 0, PROCESS_IDLE_PRIORITY);
if (!exec_dir.empty()) {
int retval = chdir(exec_dir.c_str());
#if 0
fprintf(stderr, "%s change to directory for task: %s\n",
retval ? "Failed to" : "Successful", exec_dir.c_str()
);
#endif
retval = chdir(exec_dir.c_str());
if (!retval) {
fprintf(stderr, "chdir() to %s failed\n", exec_dir.c_str());
exit(1);
}
}
// setup environment variables (if any)
@ -554,7 +552,7 @@ bool TASK::poll(int& status) {
}
}
#else
int wpid, stat;
int wpid;
struct rusage ru;
wpid = wait4(pid, &status, WNOHANG, &ru);
@ -683,9 +681,9 @@ int main(int argc, char** argv) {
double checkpoint_cpu_time;
// overall CPU time at last checkpoint
for (int i=1; i<argc; i++) {
if (!strcmp(argv[i], "--nthreads")) {
nthreads = atoi(argv[++i]);
for (int j=1; j<argc; j++) {
if (!strcmp(argv[j], "--nthreads")) {
nthreads = atoi(argv[++j]);
}
}

View File

@ -208,7 +208,7 @@ int open_database() {
// Apache will send it a SIGTERM.
// Record this in the log file and close the DB conn.
//
void sigterm_handler(int signo) {
void sigterm_handler(int /*signo*/) {
if (db_opened) {
boinc_db.close();
}
@ -340,7 +340,7 @@ void attach_to_feeder_shmem() {
}
all_apps_use_hr = true;
for (int i=0; i<ssp->napps; i++) {
for (i=0; i<ssp->napps; i++) {
if (!ssp->apps[i].homogeneous_redundancy) {
all_apps_use_hr = false;
break;