Skip to content
Snippets Groups Projects
Commit 1fc3722e authored by David Anderson's avatar David Anderson
Browse files

- client: add SCHEDULER_OP::rpc_failed();

        this gets called when the op fails, either at initialization or later on;
        it clears the project's sched_rpc_pending flag if needed.
        This fixes a bug that caused user-requested RPCs to retry every 10 seconds
        when the network is down.
    - client: if debt-adjust period is too long, reset accounting.
        Otherwise we'll get this infinitely.
    - API: all optional alpha argument to TEXTURE_DESC::draw()

svn path=/trunk/boinc/; revision=17195
parent 1686bfbb
No related branches found
No related tags found
No related merge requests found
...@@ -597,11 +597,11 @@ int read_ppm_file(const char* name, int& w, int& h, unsigned char** arrayp) { ...@@ -597,11 +597,11 @@ int read_ppm_file(const char* name, int& w, int& h, unsigned char** arrayp) {
// draw a texture at a given position and size. // draw a texture at a given position and size.
// Change size if needed so aspect ratio of texture isn't changed // Change size if needed so aspect ratio of texture isn't changed
// //
void TEXTURE_DESC::draw(float* p, float* size, int xalign, int yalign) { void TEXTURE_DESC::draw(float* p, float* size, int xalign, int yalign, float alpha) {
float pos[3]; float pos[3];
float tratio, sratio, new_size; float tratio, sratio, new_size;
memcpy(pos, p, sizeof(pos)); memcpy(pos, p, sizeof(pos));
glColor4f(1.,1.,1.,1.); glColor4f(1.,1.,1.,alpha);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, id); glBindTexture(GL_TEXTURE_2D, id);
......
...@@ -211,7 +211,7 @@ struct TEXTURE_DESC { ...@@ -211,7 +211,7 @@ struct TEXTURE_DESC {
double xsize; // size of underlying image double xsize; // size of underlying image
double ysize; double ysize;
TEXTURE_DESC() : present(false),id(0),xsize(0),ysize(0) {}; TEXTURE_DESC() : present(false),id(0),xsize(0),ysize(0) {};
void draw(float* pos, float* size, int xalign, int yalign); void draw(float* pos, float* size, int xalign, int yalign, float alpha=1.);
int load_image_file(const char* filename); int load_image_file(const char* filename);
int CreateTextureJPG(const char* strFileName); int CreateTextureJPG(const char* strFileName);
int CreateTextureBMP(const char* strFileName); int CreateTextureBMP(const char* strFileName);
......
...@@ -1358,3 +1358,25 @@ Charlie 10 Feb 2009 ...@@ -1358,3 +1358,25 @@ Charlie 10 Feb 2009
Mac_Saver_Module.h Mac_Saver_Module.h
screensaver.cpp screensaver.cpp
screensaver_win.h screensaver_win.h
David 10 Feb 2009
- client: add SCHEDULER_OP::rpc_failed();
this gets called when the op fails, either at initialization or later on;
it clears the project's sched_rpc_pending flag if needed.
This fixes a bug that caused user-requested RPCs to retry every 10 seconds
when the network is down.
- client: if debt-adjust period is too long, reset accounting.
Otherwise we'll get this infinitely.
- API: all optional alpha argument to TEXTURE_DESC::draw()
api/
gutil.cpp,h
client/
cpu_sched.cpp
file_xfer.cpp
gui_http.cpp
http_curl.cpp,h
scheduler_op.cpp,h
clientscr/
ss_app.cpp
...@@ -350,6 +350,7 @@ void CLIENT_STATE::adjust_debts() { ...@@ -350,6 +350,7 @@ void CLIENT_STATE::adjust_debts() {
(int)elapsed_time, (int)WORK_FETCH_PERIOD (int)elapsed_time, (int)WORK_FETCH_PERIOD
); );
} }
reset_debt_accounting();
return; return;
} }
......
...@@ -181,10 +181,7 @@ FILE_XFER_SET::FILE_XFER_SET(HTTP_OP_SET* p) { ...@@ -181,10 +181,7 @@ FILE_XFER_SET::FILE_XFER_SET(HTTP_OP_SET* p) {
// If successful, add to the set // If successful, add to the set
// //
int FILE_XFER_SET::insert(FILE_XFER* fxp) { int FILE_XFER_SET::insert(FILE_XFER* fxp) {
int retval; http_ops->insert(fxp);
retval = http_ops->insert(fxp);
if (retval) return retval;
file_xfers.push_back(fxp); file_xfers.push_back(fxp);
set_bandwidth_limits(fxp->is_upload); set_bandwidth_limits(fxp->is_upload);
return 0; return 0;
......
...@@ -38,12 +38,11 @@ int GUI_HTTP::do_rpc(GUI_HTTP_OP* op, string url, string output_file) { ...@@ -38,12 +38,11 @@ int GUI_HTTP::do_rpc(GUI_HTTP_OP* op, string url, string output_file) {
http_op.set_proxy(&gstate.proxy_info); http_op.set_proxy(&gstate.proxy_info);
boinc_delete_file(output_file.c_str()); boinc_delete_file(output_file.c_str());
retval = http_op.init_get(url.c_str(), output_file.c_str(), true); retval = http_op.init_get(url.c_str(), output_file.c_str(), true);
if (!retval) retval = gstate.http_ops->insert(&http_op); if (retval) return retval;
if (!retval) { gstate.http_ops->insert(&http_op);
gui_http_op = op; gui_http_op = op;
state = GUI_HTTP_STATE_BUSY; state = GUI_HTTP_STATE_BUSY;
} return 0;
return retval;
} }
int GUI_HTTP::do_rpc_post(GUI_HTTP_OP* op, string url, string input_file, string output_file) { int GUI_HTTP::do_rpc_post(GUI_HTTP_OP* op, string url, string input_file, string output_file) {
...@@ -56,12 +55,11 @@ int GUI_HTTP::do_rpc_post(GUI_HTTP_OP* op, string url, string input_file, string ...@@ -56,12 +55,11 @@ int GUI_HTTP::do_rpc_post(GUI_HTTP_OP* op, string url, string input_file, string
http_op.set_proxy(&gstate.proxy_info); http_op.set_proxy(&gstate.proxy_info);
boinc_delete_file(output_file.c_str()); boinc_delete_file(output_file.c_str());
retval = http_op.init_post(url.c_str(), input_file.c_str(), output_file.c_str()); retval = http_op.init_post(url.c_str(), input_file.c_str(), output_file.c_str());
if (!retval) retval = gstate.http_ops->insert(&http_op); if (retval) return retval;
if (!retval) { gstate.http_ops->insert(&http_op);
gui_http_op = op; gui_http_op = op;
state = GUI_HTTP_STATE_BUSY; state = GUI_HTTP_STATE_BUSY;
} return 0;
return retval;
} }
bool GUI_HTTP::poll() { bool GUI_HTTP::poll() {
......
...@@ -316,7 +316,9 @@ int HTTP_OP::libcurl_exec( ...@@ -316,7 +316,9 @@ int HTTP_OP::libcurl_exec(
curlEasy = curl_easy_init(); // get a curl_easy handle to use curlEasy = curl_easy_init(); // get a curl_easy handle to use
if (!curlEasy) { if (!curlEasy) {
msg_printf(0, MSG_INTERNAL_ERROR, "Couldn't create curlEasy handle"); if (log_flags.http_debug) {
msg_printf(0, MSG_INFO, "Couldn't create curlEasy handle");
}
return ERR_HTTP_ERROR; // returns 0 (CURLM_OK) on successful handle creation return ERR_HTTP_ERROR; // returns 0 (CURLM_OK) on successful handle creation
} }
...@@ -615,9 +617,8 @@ HTTP_OP_SET::HTTP_OP_SET() { ...@@ -615,9 +617,8 @@ HTTP_OP_SET::HTTP_OP_SET() {
// Adds an HTTP_OP to the set // Adds an HTTP_OP to the set
// //
int HTTP_OP_SET::insert(HTTP_OP* ho) { void HTTP_OP_SET::insert(HTTP_OP* ho) {
http_ops.push_back(ho); http_ops.push_back(ho);
return 0;
} }
// Remove an HTTP_OP from the set // Remove an HTTP_OP from the set
......
...@@ -181,7 +181,7 @@ class HTTP_OP_SET { ...@@ -181,7 +181,7 @@ class HTTP_OP_SET {
std::vector<HTTP_OP*> http_ops; std::vector<HTTP_OP*> http_ops;
public: public:
HTTP_OP_SET(); HTTP_OP_SET();
int insert(HTTP_OP*); void insert(HTTP_OP*);
int remove(HTTP_OP*); int remove(HTTP_OP*);
int nops(); int nops();
......
...@@ -180,6 +180,25 @@ void SCHEDULER_OP::backoff(PROJECT* p, const char *reason_msg) { ...@@ -180,6 +180,25 @@ void SCHEDULER_OP::backoff(PROJECT* p, const char *reason_msg) {
p->set_min_rpc_time(gstate.now + exp_backoff, reason_msg); p->set_min_rpc_time(gstate.now + exp_backoff, reason_msg);
} }
// RPC failed, either on startup or later.
// If RPC was requested by project or acct mgr, or init,
// keep trying (subject to backoff); otherwise give up
// (the results_dur, need_work, and trickle_up cases will be retriggered)
//
void SCHEDULER_OP::rpc_failed() {
backoff(cur_proj, "scheduler request failed");
switch (cur_proj->sched_rpc_pending) {
case RPC_REASON_INIT:
case RPC_REASON_PROJECT_REQ:
case RPC_REASON_ACCT_MGR_REQ:
break;
default:
cur_proj->sched_rpc_pending = 0;
}
cur_proj = 0;
}
// low-level routine to initiate an RPC // low-level routine to initiate an RPC
// If successful, creates an HTTP_OP that must be polled // If successful, creates an HTTP_OP that must be polled
// PRECONDITION: the request file has been created // PRECONDITION: the request file has been created
...@@ -230,6 +249,7 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) { ...@@ -230,6 +249,7 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) {
get_sched_reply_filename(*p, reply_file, sizeof(reply_file)); get_sched_reply_filename(*p, reply_file, sizeof(reply_file));
http_op.set_proxy(&gstate.proxy_info); http_op.set_proxy(&gstate.proxy_info);
cur_proj = p;
retval = http_op.init_post(scheduler_url, request_file, reply_file); retval = http_op.init_post(scheduler_url, request_file, reply_file);
if (retval) { if (retval) {
if (log_flags.sched_ops) { if (log_flags.sched_ops) {
...@@ -237,21 +257,11 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) { ...@@ -237,21 +257,11 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) {
"Scheduler request failed: %s", boincerror(retval) "Scheduler request failed: %s", boincerror(retval)
); );
} }
backoff(p, "scheduler request failed"); rpc_failed();
return retval;
}
retval = http_ops->insert(&http_op);
if (retval) {
if (log_flags.sched_ops) {
msg_printf(p, MSG_INFO,
"Scheduler request failed: %s", boincerror(retval)
);
}
backoff(p, "scheduler request failed");
return retval; return retval;
} }
http_ops->insert(&http_op);
p->rpc_seqno++; p->rpc_seqno++;
cur_proj = p; // remember what project we're talking to
state = SCHEDULER_OP_STATE_RPC; state = SCHEDULER_OP_STATE_RPC;
return 0; return 0;
} }
...@@ -270,8 +280,7 @@ int SCHEDULER_OP::init_master_fetch(PROJECT* p) { ...@@ -270,8 +280,7 @@ int SCHEDULER_OP::init_master_fetch(PROJECT* p) {
http_op.set_proxy(&gstate.proxy_info); http_op.set_proxy(&gstate.proxy_info);
retval = http_op.init_get(p->master_url, master_filename, true); retval = http_op.init_get(p->master_url, master_filename, true);
if (retval) return retval; if (retval) return retval;
retval = http_ops->insert(&http_op); http_ops->insert(&http_op);
if (retval) return retval;
cur_proj = p; cur_proj = p;
state = SCHEDULER_OP_STATE_GET_MASTER; state = SCHEDULER_OP_STATE_GET_MASTER;
return 0; return 0;
...@@ -448,22 +457,7 @@ bool SCHEDULER_OP::poll() { ...@@ -448,22 +457,7 @@ bool SCHEDULER_OP::poll() {
if (!retval) return true; if (!retval) return true;
} }
if (url_index == (int) cur_proj->scheduler_urls.size()) { if (url_index == (int) cur_proj->scheduler_urls.size()) {
backoff(cur_proj, "scheduler request failed"); rpc_failed();
// if RPC was requested by project or acct mgr, or init,
// keep trying (subject to backoff);
// otherwise give up
// (the results_dur, need_work, and trickle_up cases
// will be retriggered)
//
switch (cur_proj->sched_rpc_pending) {
case RPC_REASON_INIT:
case RPC_REASON_PROJECT_REQ:
case RPC_REASON_ACCT_MGR_REQ:
break;
default:
cur_proj->sched_rpc_pending = 0;
}
} }
} else { } else {
retval = gstate.handle_scheduler_reply(cur_proj, scheduler_url); retval = gstate.handle_scheduler_reply(cur_proj, scheduler_url);
......
...@@ -83,6 +83,7 @@ private: ...@@ -83,6 +83,7 @@ private:
bool update_urls(PROJECT*, std::vector<std::string> &urls); bool update_urls(PROJECT*, std::vector<std::string> &urls);
int start_op(PROJECT*); int start_op(PROJECT*);
int start_rpc(PROJECT*); int start_rpc(PROJECT*);
void rpc_failed();
int parse_master_file(PROJECT*, std::vector<std::string>&); int parse_master_file(PROJECT*, std::vector<std::string>&);
}; };
......
...@@ -88,11 +88,11 @@ static void init_lights() { ...@@ -88,11 +88,11 @@ static void init_lights() {
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir); glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir);
} }
static void draw_logo() { static void draw_logo(float alpha) {
if (logo.present) { if (logo.present) {
float pos[3] = {.2, .3, 0}; float pos[3] = {.2, .3, 0};
float size[3] = {.6, .4, 0}; float size[3] = {.6, .4, 0};
logo.draw(pos, size, ALIGN_CENTER, ALIGN_CENTER); logo.draw(pos, size, ALIGN_CENTER, ALIGN_CENTER, alpha);
} }
} }
...@@ -144,12 +144,12 @@ PROJECT_IMAGES* get_project_images(PROJECT* p) { ...@@ -144,12 +144,12 @@ PROJECT_IMAGES* get_project_images(PROJECT* p) {
return &(project_images.back()); return &(project_images.back());
} }
void show_result(RESULT* r, float x, float& y) { void show_result(RESULT* r, float x, float& y, float alpha) {
PROGRESS progress; PROGRESS progress;
char buf[256]; char buf[256];
float prog_pos[] = {x, y, 0}; float prog_pos[] = {x, y, 0};
float prog_c[] = {.5, .4, .1, 0.5}; float prog_c[] = {.5, .4, .1, alpha/2};
float prog_ci[] = {.1, .8, .2, 1.}; float prog_ci[] = {.1, .8, .2, alpha};
txf_render_string(.1, x, y, 0, 8., white, 0, (char*)r->app->user_friendly_name.c_str()); txf_render_string(.1, x, y, 0, 8., white, 0, (char*)r->app->user_friendly_name.c_str());
y -= 3; y -= 3;
progress.init(prog_pos, 10., 1., 0.8, prog_c, prog_ci); progress.init(prog_pos, 10., 1., 0.8, prog_c, prog_ci);
...@@ -174,7 +174,8 @@ void show_coords() { ...@@ -174,7 +174,8 @@ void show_coords() {
txf_render_string(.1, 0, y, 0, 10., white, 0, buf); txf_render_string(.1, 0, y, 0, 10., white, 0, buf);
} }
} }
void show_project(PROJECT* p, float x, float& y) {
void show_project(PROJECT* p, float x, float& y, float alpha) {
unsigned int i; unsigned int i;
PROJECT_IMAGES* pim = get_project_images(p); PROJECT_IMAGES* pim = get_project_images(p);
txf_render_string(.1, x, y, 0, 5., white, 0, (char*)p->project_name.c_str()); txf_render_string(.1, x, y, 0, 5., white, 0, (char*)p->project_name.c_str());
...@@ -189,16 +190,16 @@ void show_project(PROJECT* p, float x, float& y) { ...@@ -189,16 +190,16 @@ void show_project(PROJECT* p, float x, float& y) {
if (r->project != p) continue; if (r->project != p) continue;
if (!r->active_task) continue; if (!r->active_task) continue;
if (r->active_task_state != PROCESS_EXECUTING) continue; if (r->active_task_state != PROCESS_EXECUTING) continue;
show_result(r, x, y); show_result(r, x, y, alpha);
} }
} }
void show_projects() { void show_projects(float alpha) {
float x=-45, y=30; float x=-45, y=30;
unsigned int i; unsigned int i;
for (i=0; i<cc_state.projects.size(); i++) { for (i=0; i<cc_state.projects.size(); i++) {
PROJECT* p = cc_state.projects[i]; PROJECT* p = cc_state.projects[i];
show_project(p, x, y); show_project(p, x, y, alpha);
y -= 2; y -= 2;
} }
} }
...@@ -247,13 +248,26 @@ void app_graphics_render(int xs, int ys, double t) { ...@@ -247,13 +248,26 @@ void app_graphics_render(int xs, int ys, double t) {
boinc_close_window_and_quit("RPC failed"); boinc_close_window_and_quit("RPC failed");
} }
static float alpha=1;
static float dalpha = -.01;
white[3] = alpha;
alpha += dalpha;
if (alpha < 0) {
alpha = 0;
dalpha = -dalpha;
}
if (alpha > 1) {
alpha = 1;
dalpha = -dalpha;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// draw logo first - it's in background // draw logo first - it's in background
// //
mode_unshaded(); mode_unshaded();
mode_ortho(); mode_ortho();
draw_logo(); draw_logo(alpha);
ortho_done(); ortho_done();
// draw 3D objects // draw 3D objects
...@@ -266,9 +280,11 @@ void app_graphics_render(int xs, int ys, double t) { ...@@ -266,9 +280,11 @@ void app_graphics_render(int xs, int ys, double t) {
// //
//mode_unshaded(); //mode_unshaded();
//mode_ortho(); //mode_ortho();
show_projects(); show_projects(alpha);
show_coords(); show_coords();
//ortho_done(); //ortho_done();
} }
void app_graphics_resize(int w, int h){ void app_graphics_resize(int w, int h){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment