summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-08-23 19:51:55 +0400
committerAlexander Gavrilov2012-08-23 19:51:55 +0400
commitb12b9fa91e3be0d4d157f144f4b20202cdb72917 (patch)
tree23ee4c6c4bc8d6844823152769f562f380f33728 /library
parentc6c5ad56c9b4421e1bf8a5bc2f38323734a9d2eb (diff)
downloaddfhack-b12b9fa91e3be0d4d157f144f4b20202cdb72917.tar.gz
dfhack-b12b9fa91e3be0d4d157f144f4b20202cdb72917.tar.bz2
dfhack-b12b9fa91e3be0d4d157f144f4b20202cdb72917.tar.xz
Suspend DF around loading and unloading plugins.
This is necessary to improve safety of vtable interposing.
Diffstat (limited to 'library')
-rw-r--r--library/Core.cpp1
-rw-r--r--library/PluginManager.cpp5
2 files changed, 6 insertions, 0 deletions
diff --git a/library/Core.cpp b/library/Core.cpp
index 71c92afe..a61fef4e 100644
--- a/library/Core.cpp
+++ b/library/Core.cpp
@@ -1225,6 +1225,7 @@ int Core::Shutdown ( void )
if(errorstate)
return true;
errorstate = 1;
+ CoreSuspendClaimer suspend;
if(plug_mgr)
{
delete plug_mgr;
diff --git a/library/PluginManager.cpp b/library/PluginManager.cpp
index 3c015b2a..d8b9ff27 100644
--- a/library/PluginManager.cpp
+++ b/library/PluginManager.cpp
@@ -195,6 +195,9 @@ bool Plugin::load(color_ostream &con)
{
return true;
}
+ // enter suspend
+ CoreSuspender suspend;
+ // open the library, etc
DFLibrary * plug = OpenPlugin(filename.c_str());
if(!plug)
{
@@ -270,6 +273,8 @@ bool Plugin::unload(color_ostream &con)
}
// wait for all calls to finish
access->wait();
+ // enter suspend
+ CoreSuspender suspend;
// notify plugin about shutdown, if it has a shutdown function
command_result cr = CR_OK;
if(plugin_shutdown)