diff --git a/winixd/core/app.cpp b/winixd/core/app.cpp index 5e5b688..7091349 100644 --- a/winixd/core/app.cpp +++ b/winixd/core/app.cpp @@ -408,7 +408,7 @@ void App::Close() { Winix::Lock lock(synchro); - plugin.Call((Winix::Session*)0, WINIX_CLOSE); + plugin.Call((Winix::Session*)0, WINIX_PREPARE_TO_CLOSE); session_manager.SaveSessions(); session_manager.DeleteSessions(); @@ -421,6 +421,17 @@ void App::Close() WaitForThreads(); // now all others threads are terminated + + /* + * at the moment plugins are removed when winix is finishing + * but in the future we can add plug-in removal before the end + */ + plugin.Call(nullptr, WINIX_PLUGIN_QUIT); + + /* + * this is the last message for plugins + */ + plugin.Call(nullptr, WINIX_QUIT); } diff --git a/winixd/core/pluginmsg.h b/winixd/core/pluginmsg.h index 0a9b239..fbdd42e 100644 --- a/winixd/core/pluginmsg.h +++ b/winixd/core/pluginmsg.h @@ -107,10 +107,14 @@ namespace Winix // in l1 you have the old session id #define WINIX_SESSION_REMOVED 30029 -// the winix is closing +// the winix is being closing // there is not any sessions available (cur->session is null) // session pointer is null -#define WINIX_CLOSE 30040 +#define WINIX_PREPARE_TO_CLOSE 30040 + +// winix has been closes, all other threads are stopped now, this is a last message for the main thread +// there is not any sessions available (cur->session is null) +#define WINIX_QUIT 30041 // preparing to remove a file (rm function) // in p1 you have a pointer to the Item struct (file) @@ -142,6 +146,11 @@ namespace Winix // session pointer is null #define WINIX_PLUGIN_INIT 30080 +// winix is ready to remove a plugin +// you can clear some plugin data here e.g. controllers +// all other threads are stopped now +#define WINIX_PLUGIN_QUIT 30081 + // here you can add your own mount point, file systems, mount parameters // for adding a new mount type call: system->mounts.AddMountType("new_mount_name") // session pointer is null diff --git a/winixd/plugins/stats/init.cpp b/winixd/plugins/stats/init.cpp index c5b2949..ada7365 100644 --- a/winixd/plugins/stats/init.cpp +++ b/winixd/plugins/stats/init.cpp @@ -230,7 +230,7 @@ using namespace Stats; info.plugin->Assign(WINIX_CONTENT_MAKE, ContentMake); info.plugin->Assign(WINIX_SESSION_CREATED, SessionCreated); info.plugin->Assign(WINIX_PLUGIN_SESSION_DATA_REMOVE, RemoveSession); - info.plugin->Assign(WINIX_CLOSE, Close); + info.plugin->Assign(WINIX_PREPARE_TO_CLOSE, Close); info.plugin->Assign(WINIX_FILE_REMOVED, RemoveFile); info.plugin->Assign(WINIX_DIR_PREPARE_TO_REMOVE, RemoveDir);