From c2c29af95981a9b60cba9fa92c47be3870409a65 Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 25 Jun 2012 19:16:35 +0200 Subject: [PATCH] ruby: fix deadlock on df exit due to BEGIN_UNLOAD + Core.Suspend() --- plugins/ruby/README | 3 ++- plugins/ruby/ruby.cpp | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/ruby/README b/plugins/ruby/README index e4f22c71d..690e83ca0 100644 --- a/plugins/ruby/README +++ b/plugins/ruby/README @@ -116,7 +116,8 @@ To register ruby code to be run every graphic frame, use: To stop being called, use: df.onupdate_unregister handle -The same mechanism is available for 'onstatechange'. +The same mechanism is available for 'onstatechange', but the +SC_BEGIN_UNLOAD event is not propagated to the ruby handler. C++ object manipulation diff --git a/plugins/ruby/ruby.cpp b/plugins/ruby/ruby.cpp index d4271c54a..8ec6ac464 100644 --- a/plugins/ruby/ruby.cpp +++ b/plugins/ruby/ruby.cpp @@ -181,7 +181,9 @@ DFhackCExport command_result plugin_onstatechange ( color_ostream &out, state_ch SCASE(MAP_UNLOADED); SCASE(VIEWSCREEN_CHANGED); SCASE(CORE_INITIALIZED); - SCASE(BEGIN_UNLOAD); + // if we go through plugin_eval at BEGIN_UNLOAD, it'll + // try to get the suspend lock and deadlock at df exit + case SC_BEGIN_UNLOAD : return CR_OK; #undef SCASE }