diff --git a/api/gutil.cpp b/api/gutil.cpp index bafa4a5002aac98e9e8b8b9ce9b36ba7e21a7928..733855a3d6a6cf70c190681af99f3f333523121e 100644 --- a/api/gutil.cpp +++ b/api/gutil.cpp @@ -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. // 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 tratio, sratio, new_size; memcpy(pos, p, sizeof(pos)); - glColor4f(1.,1.,1.,1.); + glColor4f(1.,1.,1.,alpha); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id); diff --git a/api/gutil.h b/api/gutil.h index df167ca26e4ba9c848cc9b6fcf2d2921a3cded11..69e591b09f44a4f67845592f76350e4fae0f86e7 100644 --- a/api/gutil.h +++ b/api/gutil.h @@ -211,7 +211,7 @@ struct TEXTURE_DESC { double xsize; // size of underlying image double ysize; 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 CreateTextureJPG(const char* strFileName); int CreateTextureBMP(const char* strFileName); diff --git a/checkin_notes b/checkin_notes index f247a076d33b1de466986a395c9436e3be978991..5b316b83eadffa82b1029978297e56d51fc8e7f0 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1358,3 +1358,25 @@ Charlie 10 Feb 2009 Mac_Saver_Module.h screensaver.cpp 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 diff --git a/client/cpu_sched.cpp b/client/cpu_sched.cpp index f32b793d1e06f337b5fcc90b26726e43d561f003..6d3ab5f639cba5b701e82304785767ce0795f066 100644 --- a/client/cpu_sched.cpp +++ b/client/cpu_sched.cpp @@ -350,6 +350,7 @@ void CLIENT_STATE::adjust_debts() { (int)elapsed_time, (int)WORK_FETCH_PERIOD ); } + reset_debt_accounting(); return; } diff --git a/client/file_xfer.cpp b/client/file_xfer.cpp index f4b42cc0acd5717b15dc88eec8a195890c8ab4a1..20d033e198741c952a81f9378241c3e08568bb0c 100644 --- a/client/file_xfer.cpp +++ b/client/file_xfer.cpp @@ -181,10 +181,7 @@ FILE_XFER_SET::FILE_XFER_SET(HTTP_OP_SET* p) { // If successful, add to the set // int FILE_XFER_SET::insert(FILE_XFER* fxp) { - int retval; - - retval = http_ops->insert(fxp); - if (retval) return retval; + http_ops->insert(fxp); file_xfers.push_back(fxp); set_bandwidth_limits(fxp->is_upload); return 0; diff --git a/client/gui_http.cpp b/client/gui_http.cpp index a727b278e2805ea18a0f4386ad177c156bb3e2a9..1e2fb6f822ae5c2b8b740f3b5f430177a05474f5 100644 --- a/client/gui_http.cpp +++ b/client/gui_http.cpp @@ -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); boinc_delete_file(output_file.c_str()); retval = http_op.init_get(url.c_str(), output_file.c_str(), true); - if (!retval) retval = gstate.http_ops->insert(&http_op); - if (!retval) { - gui_http_op = op; - state = GUI_HTTP_STATE_BUSY; - } - return retval; + if (retval) return retval; + gstate.http_ops->insert(&http_op); + gui_http_op = op; + state = GUI_HTTP_STATE_BUSY; + return 0; } 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 http_op.set_proxy(&gstate.proxy_info); boinc_delete_file(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) { - gui_http_op = op; - state = GUI_HTTP_STATE_BUSY; - } - return retval; + if (retval) return retval; + gstate.http_ops->insert(&http_op); + gui_http_op = op; + state = GUI_HTTP_STATE_BUSY; + return 0; } bool GUI_HTTP::poll() { diff --git a/client/http_curl.cpp b/client/http_curl.cpp index 6260fed6798f3cb55f2803a649956e8b47349f6f..0b31e17dbc8ad62b245a51cd2e273dacf2a33c74 100644 --- a/client/http_curl.cpp +++ b/client/http_curl.cpp @@ -316,7 +316,9 @@ int HTTP_OP::libcurl_exec( curlEasy = curl_easy_init(); // get a curl_easy handle to use 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 } @@ -615,9 +617,8 @@ HTTP_OP_SET::HTTP_OP_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); - return 0; } // Remove an HTTP_OP from the set diff --git a/client/http_curl.h b/client/http_curl.h index 267002be3b4aca075153c3a3f4e4ec036ca9fa0b..89d7f51be601e0461cf03b80ae69fdf35c91a30c 100644 --- a/client/http_curl.h +++ b/client/http_curl.h @@ -181,7 +181,7 @@ class HTTP_OP_SET { std::vector<HTTP_OP*> http_ops; public: HTTP_OP_SET(); - int insert(HTTP_OP*); + void insert(HTTP_OP*); int remove(HTTP_OP*); int nops(); diff --git a/client/scheduler_op.cpp b/client/scheduler_op.cpp index 93024df2dc934b28b5aaaa382b4b19f392bfe156..dcec226cb5a48662ca06532bc108c32644b3632f 100644 --- a/client/scheduler_op.cpp +++ b/client/scheduler_op.cpp @@ -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); } + +// 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 // If successful, creates an HTTP_OP that must be polled // PRECONDITION: the request file has been created @@ -230,6 +249,7 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) { get_sched_reply_filename(*p, reply_file, sizeof(reply_file)); http_op.set_proxy(&gstate.proxy_info); + cur_proj = p; retval = http_op.init_post(scheduler_url, request_file, reply_file); if (retval) { if (log_flags.sched_ops) { @@ -237,21 +257,11 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) { "Scheduler request failed: %s", boincerror(retval) ); } - backoff(p, "scheduler request 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"); + rpc_failed(); return retval; } + http_ops->insert(&http_op); p->rpc_seqno++; - cur_proj = p; // remember what project we're talking to state = SCHEDULER_OP_STATE_RPC; return 0; } @@ -270,8 +280,7 @@ int SCHEDULER_OP::init_master_fetch(PROJECT* p) { http_op.set_proxy(&gstate.proxy_info); retval = http_op.init_get(p->master_url, master_filename, true); if (retval) return retval; - retval = http_ops->insert(&http_op); - if (retval) return retval; + http_ops->insert(&http_op); cur_proj = p; state = SCHEDULER_OP_STATE_GET_MASTER; return 0; @@ -448,22 +457,7 @@ bool SCHEDULER_OP::poll() { if (!retval) return true; } if (url_index == (int) cur_proj->scheduler_urls.size()) { - backoff(cur_proj, "scheduler request 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; - } + rpc_failed(); } } else { retval = gstate.handle_scheduler_reply(cur_proj, scheduler_url); diff --git a/client/scheduler_op.h b/client/scheduler_op.h index cf152efb6d205ee5770977778e3e5804feaa9902..e39e5c1dfe2a72e5c5aa068d4ad7ac5cdc38cefa 100644 --- a/client/scheduler_op.h +++ b/client/scheduler_op.h @@ -83,6 +83,7 @@ private: bool update_urls(PROJECT*, std::vector<std::string> &urls); int start_op(PROJECT*); int start_rpc(PROJECT*); + void rpc_failed(); int parse_master_file(PROJECT*, std::vector<std::string>&); }; diff --git a/clientscr/ss_app.cpp b/clientscr/ss_app.cpp index fe8f54138a96612790b01bdf011d4927f33cfe42..f2fe4e0a0246dddb572d403189705e1127b5e400 100644 --- a/clientscr/ss_app.cpp +++ b/clientscr/ss_app.cpp @@ -88,11 +88,11 @@ static void init_lights() { glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir); } -static void draw_logo() { +static void draw_logo(float alpha) { if (logo.present) { float pos[3] = {.2, .3, 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) { 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; char buf[256]; float prog_pos[] = {x, y, 0}; - float prog_c[] = {.5, .4, .1, 0.5}; - float prog_ci[] = {.1, .8, .2, 1.}; + float prog_c[] = {.5, .4, .1, alpha/2}; + 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()); y -= 3; progress.init(prog_pos, 10., 1., 0.8, prog_c, prog_ci); @@ -174,7 +174,8 @@ void show_coords() { 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; PROJECT_IMAGES* pim = get_project_images(p); 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) { if (r->project != p) continue; if (!r->active_task) 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; unsigned int i; for (i=0; i<cc_state.projects.size(); i++) { PROJECT* p = cc_state.projects[i]; - show_project(p, x, y); + show_project(p, x, y, alpha); y -= 2; } } @@ -247,13 +248,26 @@ void app_graphics_render(int xs, int ys, double t) { 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); // draw logo first - it's in background // mode_unshaded(); mode_ortho(); - draw_logo(); + draw_logo(alpha); ortho_done(); // draw 3D objects @@ -266,9 +280,11 @@ void app_graphics_render(int xs, int ys, double t) { // //mode_unshaded(); //mode_ortho(); - show_projects(); + show_projects(alpha); show_coords(); //ortho_done(); + + } void app_graphics_resize(int w, int h){