diff --git a/api/boinc_api.C b/api/boinc_api.C index f7188cb58e..7a31c6d5a6 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -56,7 +56,6 @@ using namespace std; #ifdef __cplusplus extern "C" { #endif -//extern int boinc_shutdown_graphics(); #ifdef __cplusplus } #endif @@ -84,6 +83,7 @@ extern "C" { // Unless otherwise noted, "CPU time" refers to the sum over all episodes // (not counting the part after the last checkpoint in an episode). +void (*stop_graphics_thread_ptr)() = 0; static APP_INIT_DATA aid; static FILE_LOCK file_lock; APP_CLIENT_SHM* app_client_shm = 0; @@ -376,13 +376,14 @@ int boinc_finish(int status) { // unlock the lockfile and call the appropriate exit function +// This is called from the worker thread or the timer thread. // void boinc_exit(int status) { -#ifdef BOINC_APP_GRAPHICS - // Shutdown graphics if it is running + // Shutdown graphics thread if it is running // - //boinc_shutdown_graphics(); -#endif + if (stop_graphics_thread_ptr) { + (*stop_graphics_thread_ptr)(); + } // Unlock the lock file // diff --git a/api/boinc_api.h b/api/boinc_api.h index 3ebc609069..33ed09b527 100755 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -131,6 +131,7 @@ extern void block_sigalrm(); #endif extern int boinc_init_options_general(BOINC_OPTIONS& opt); extern int set_worker_timer(void); +extern void (*stop_graphics_thread_ptr)(); inline void boinc_options_defaults(BOINC_OPTIONS& b) { b.main_program = true; diff --git a/api/graphics_api.C b/api/graphics_api.C index f6da01dcf5..d0ea148897 100755 --- a/api/graphics_api.C +++ b/api/graphics_api.C @@ -39,10 +39,6 @@ int boinc_init_graphics(void (*worker)()) { return boinc_init_graphics_impl(worker, &boinc_main_state); } -int boinc_shutdown_graphics() { - return boinc_shutdown_graphics_impl(&boinc_main_state); -} - int boinc_init_options_graphics(BOINC_OPTIONS& opt, void (*worker)()) { init_main_state(); return boinc_init_options_graphics_impl(opt, worker, &boinc_main_state); diff --git a/api/graphics_api.h b/api/graphics_api.h index b05f953bbc..4fc96e88b6 100755 --- a/api/graphics_api.h +++ b/api/graphics_api.h @@ -37,7 +37,6 @@ extern "C" { typedef void (*WORKER_FUNC_PTR)(); extern int boinc_init_graphics(WORKER_FUNC_PTR); -extern int boinc_shutdown_graphics(); // Functions that must be supplied by the app // diff --git a/api/graphics_impl.C b/api/graphics_impl.C index fa1277ebef..cae1c97872 100755 --- a/api/graphics_impl.C +++ b/api/graphics_impl.C @@ -31,7 +31,6 @@ #ifdef _WIN32 extern void win_graphics_event_loop(); -extern void win_graphics_shutdown_event_loop(); #else #include #include @@ -84,11 +83,6 @@ int boinc_init_graphics_impl(WORKER_FUNC_PTR worker, BOINC_MAIN_STATE* bmsp) { return boinc_init_options_graphics_impl(opt, worker, bmsp); } -// the following function can be in a shared library, -int boinc_shutdown_graphics_impl(BOINC_MAIN_STATE* bmsp) { - return boinc_shutdown_options_graphics_impl(bmsp); -} - int start_worker_thread(WORKER_FUNC_PTR _worker_main) { worker_main = _worker_main; #ifdef _WIN32 @@ -179,15 +173,6 @@ int boinc_init_options_graphics_impl( return 0; } -int boinc_shutdown_options_graphics_impl( - BOINC_MAIN_STATE* bmsp -) { -#ifdef _WIN32 - win_graphics_shutdown_event_loop(); -#endif - return 0; -} - #ifndef _WIN32 extern "C" { void glut_quit() { diff --git a/api/graphics_impl.h b/api/graphics_impl.h index 9eca45be5c..4eefb2b998 100644 --- a/api/graphics_impl.h +++ b/api/graphics_impl.h @@ -40,10 +40,6 @@ extern int boinc_init_graphics_impl( WORKER_FUNC_PTR worker, BOINC_MAIN_STATE* ); -extern int boinc_shutdown_graphics_impl( - BOINC_MAIN_STATE* -); - // This extern C is needed to make this code work correctly, // even in a 100% C++ context. // This is because we need to dlsym() resolve this function. @@ -57,9 +53,6 @@ extern "C" { WORKER_FUNC_PTR _worker_main, BOINC_MAIN_STATE* ); - extern int boinc_shutdown_options_graphics_impl( - BOINC_MAIN_STATE* - ); } extern BOINC_MAIN_STATE* g_bmsp; diff --git a/api/windows_opengl.C b/api/windows_opengl.C index e861230e60..e27f4b816f 100755 --- a/api/windows_opengl.C +++ b/api/windows_opengl.C @@ -488,9 +488,34 @@ static VOID CALLBACK timer_handler(HWND, UINT, UINT, DWORD) { } } +// This is called from the worker or multimedia timer thread, +// when it's preparing to exit. +// Shut down the graphics thread to avoid crash on exit. +// +static void stop_graphics_thread() { + // Shutdown the timer and stop processing messages + // + if (gfx_timer_id) { + KillTimer(NULL, gfx_timer_id); + gfx_timer_id = NULL; + } + + // Process any outstanding messages + // + Sleep(0); + + // Close down any open window and clean up + // + if (!boinc_is_standalone()) { + set_mode(MODE_HIDE_GRAPHICS); + } +} + void win_graphics_event_loop() { MSG msg; // Windows Message Structure + stop_graphics_thread_ptr = stop_graphics_thread; + // Detect platform information OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof(osvi); @@ -522,24 +547,4 @@ void win_graphics_event_loop() { SetEvent(hQuitEvent); // Signal the worker thread that we're quitting } -void win_graphics_shutdown_event_loop() { - // Shutdown the timer and stop processing messages - // - if (gfx_timer_id) { - KillTimer(NULL, gfx_timer_id); - gfx_timer_id = NULL; - } - - // Process any outstanding messages and stuff before moving - // on. - // - Sleep(0); - - // Close down any open window and cleanup - // - if (!boinc_is_standalone()) { - set_mode(MODE_HIDE_GRAPHICS); - } -} - const char *BOINC_RCSID_462f482d81 = "$Id$"; diff --git a/checkin_notes b/checkin_notes index 5ab281fbc6..e4be2278e5 100755 --- a/checkin_notes +++ b/checkin_notes @@ -12048,3 +12048,22 @@ David 22 Sept 2005 user/ edit_passwd_action.php login_action.php + +David 23 Sept 2005 + - Redo the "clean up graphics thread before exit" logic. + boinc_api.C now has a function pointer that gets set + (in the Windows graphics case) to point to a cleanup function. + This gets called in boinc_exit(). + + Got rid of boinc_shutdown_graphics_impl(), + boinc_shutdown_options_graphics_impl(), boinc_shutdown_graphics(). + Let's try to keep it simple. + + TODO: it's not clear to me that the graphics cleanup function + will actually work. Rom's going to redo it. + + api/ + boinc_api.C,h + graphics_api.C,h + graphics_impl.C,h + windows_opengl.C diff --git a/doc/boinc_news.inc b/doc/boinc_news.inc index 99757a1104..e248d1f805 100644 --- a/doc/boinc_news.inc +++ b/doc/boinc_news.inc @@ -2,6 +2,10 @@ $project_news = array( +array("September 23, 2005", + "High-Performance Task Distribution for Volunteer Computing, a paper about BOINC server performance, + will appear in the e-Science 2005 conference in December." +), array("September 6, 2005", "Searching for Gravity @ Home, an article about Einstein@home and BOINC, appears in the September 2005 issue of IEEE's The Institute." diff --git a/doc/index.php b/doc/index.php index b25fffded9..dcd0402672 100644 --- a/doc/index.php +++ b/doc/index.php @@ -98,7 +98,8 @@ resources
  • Personnel and contact info
  • BOINC email lists
  • BOINC message boards -
  • An overview of BOINC, and links to papers +
  • An overview of BOINC +
  • Papers about BOINC
  • How to get involved in