From 177b530d0b728110097af9770b72799dfd765c51 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 28 Dec 2004 03:39:52 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4951 --- api/x_opengl.C | 24 ++++++++++++++++-------- checkin_notes | 17 +++++++++++++++++ lib/util.h | 2 +- sched/main.C | 1 + sched/sched_send.C | 7 +++++-- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/api/x_opengl.C b/api/x_opengl.C index 5ee28f48e3..bb29e82be9 100644 --- a/api/x_opengl.C +++ b/api/x_opengl.C @@ -193,23 +193,31 @@ void xwin_graphics_event_loop() { char* args[] = {"foobar", 0}; int one=1; static bool glut_inited = false; + int restarted; graphics_thread = pthread_self(); atexit(restart); - int restarted = setjmp(jbuf); + +try_again: + restarted = setjmp(jbuf); if (restarted) { - if (!glut_inited) { - // here glutInit() must have failed and called exit(). - // returning will cause the graphics thread to exit. - return; - } //fprintf(stderr, "graphics thread restarted\n"); fflush(stderr); + if (glut_inited) { + // here the user must have closed the window, + // which causes GLUT to call exit(). + // #ifdef __APPLE_CC__ - glutInit(&one, args); + glutInit(&one, args); #endif - set_mode(MODE_HIDE_GRAPHICS); + set_mode(MODE_HIDE_GRAPHICS); + } else { + // here glutInit() must have failed and called exit(). + // + sleep(60); + goto try_again; + } } else { glutInit(&one, args); glut_inited = true; diff --git a/checkin_notes b/checkin_notes index 395e5b3dbb..2dd05af64a 100755 --- a/checkin_notes +++ b/checkin_notes @@ -21893,3 +21893,20 @@ David 27 Dec 2004 login_action.php tools/ upgrade + +David 27 Dec 2004 + - UNIX app graphics: if glutInit() fails, keep retrying periodically + (in case user runs X server, e.g.) + - scheduler: scan the work array from a random point, + instead of always from the start. + This prevents a result from getting stuck at the end + of the array, and possibly never getting sent. + (from Ben Herndon) + + api/ + x_opengl.C + lib/ + util.h + sched/ + main.C + sched_send.C diff --git a/lib/util.h b/lib/util.h index 3750cb2963..0320f1d034 100755 --- a/lib/util.h +++ b/lib/util.h @@ -88,7 +88,7 @@ static inline double drand() { return (double)rand()/(double)RAND_MAX; } -// return a random integer in the range [rmin,rmax) +// return a random double in the range [rmin,rmax) static inline double rand_range(double rmin, double rmax) { if (rmin < rmax) { return drand() * (rmax-rmin) + rmin; diff --git a/sched/main.C b/sched/main.C index 18235d5e41..74cfb39d23 100644 --- a/sched/main.C +++ b/sched/main.C @@ -108,6 +108,7 @@ int main() { } #endif + srand(time(0)+getpid()); log_messages.set_debug_level(DEBUG_LEVEL); if (check_stop_sched()) { diff --git a/sched/sched_send.C b/sched/sched_send.C index c3452e96f8..e9675413f8 100644 --- a/sched/sched_send.C +++ b/sched/sched_send.C @@ -523,7 +523,7 @@ static void scan_work_array( SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, PLATFORM& platform, SCHED_SHMEM& ss ) { - int i, retval, n; + int i, j, retval, n, rnd_off; WORKUNIT wu; DB_RESULT result; char buf[256]; @@ -534,7 +534,10 @@ static void scan_work_array( if (wreq.disk_available < 0) wreq.insufficient_disk = true; lock_sema(); - for (i=0; i