diff options
author | Adam <Adam@anope.org> | 2013-04-06 19:34:35 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-04-06 19:34:35 -0500 |
commit | 36602224b8b1a11326a224779d16bcb12f0ed532 (patch) | |
tree | a542057c83aab53bc1c3d50cf300b2f64ebf6143 | |
parent | ccecfdf44506d97874cdd1bc8b73a273188310c4 (diff) |
Remove the runtime module directory on non-windows because we no longer overwrite modules on install without deleting them first
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | include/modules.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/modulemanager.cpp | 12 |
4 files changed, 17 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d727b84f7..83a2bb455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -483,12 +483,13 @@ get_filename_component(SERVICES_BINARY ${SERVICES_BINARY} NAME) # At install time, create the following additional directories install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${DB_DIR}/backups\")") install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${LOGS_DIR}\")") -install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${DB_DIR}/runtime\")") +if(WIN32) + install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${DB_DIR}/runtime\")") +endif(WIN32) # On non-Windows platforms, if RUNGROUP is set, change the permissions of the below directories, as well as the group of the data directory if(NOT WIN32 AND RUNGROUP) install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${CMAKE_INSTALL_PREFIX}/\${DB_DIR}/backups\")") install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${CMAKE_INSTALL_PREFIX}/\${LOGS_DIR}\")") - install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${CMAKE_INSTALL_PREFIX}/\${DB_DIR}/runtime\")") install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"\${CMAKE_INSTALL_PREFIX}\")") endif(NOT WIN32 AND RUNGROUP) # On Windows platforms, install extra files diff --git a/include/modules.h b/include/modules.h index 10b9ed8aa..22a3b9ce7 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1032,9 +1032,11 @@ class CoreExport ModuleManager */ static std::vector<Module *> EventHandlers[I_END]; +#ifdef _WIN32 /** Clean up the module runtime directory */ static void CleanupRuntimeDirectory(); +#endif /** Loads a given module. * @param m the module to load diff --git a/src/main.cpp b/src/main.cpp index 0bac78e72..2e15f5874 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,10 +117,10 @@ int main(int ac, char **av, char **envp) #endif Anope::ServicesDir = BinaryDir.substr(0, n); +#ifdef _WIN32 /* Clean out the module runtime directory prior to running, just in case files were left behind during a previous run */ ModuleManager::CleanupRuntimeDirectory(); -#ifdef _WIN32 OnStartup(); #endif @@ -187,9 +187,9 @@ int main(int ac, char **av, char **envp) for (Module *m; (m = ModuleManager::FindFirstOf(PROTOCOL)) != NULL;) ModuleManager::UnloadModule(m, NULL); +#ifdef _WIN32 ModuleManager::CleanupRuntimeDirectory(); -#ifdef _WIN32 OnShutdown(); #endif diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 823fda868..229067979 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -23,6 +23,7 @@ std::list<Module *> ModuleManager::Modules; std::vector<Module *> ModuleManager::EventHandlers[I_END]; +#ifdef _WIN32 void ModuleManager::CleanupRuntimeDirectory() { Anope::string dirbuf = Anope::DataDir + "/runtime"; @@ -108,6 +109,7 @@ static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &out return !source.fail() && !target.fail() ? MOD_ERR_OK : MOD_ERR_FILE_IO; } +#endif /* This code was found online at http://www.linuxjournal.com/article/3687#comment-26593 * @@ -133,8 +135,9 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) if (FindModule(modname)) return MOD_ERR_EXISTS; - Log(LOG_DEBUG) << "trying to load [" << modname << "]"; + Log(LOG_DEBUG) << "Trying to load module: " << modname; +#ifdef _WIN32 /* Generate the filename for the temporary copy of the module */ Anope::string pbuf = Anope::DataDir + "/runtime/" + modname + ".so.XXXXXX"; @@ -148,6 +151,9 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) Log(LOG_TERMINAL) << "Error while loading " << modname << " (file IO error, check file permissions and diskspace)"; return ret; } +#else + Anope::string pbuf = Anope::ModuleDir + "/modules/" + modname + ".so"; +#endif dlerror(); void *handle = dlopen(pbuf.c_str(), RTLD_NOW); @@ -219,7 +225,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) else Log(LOG_DEBUG_2) << "Module " << modname << " is compiled against current version of Anope " << Anope::VersionShort(); - Log(LOG_DEBUG) << "Module loaded."; + Log(LOG_DEBUG) << "Module " << modname << " loaded."; FOREACH_MOD(I_OnModuleLoad, OnModuleLoad(u, m)); return MOD_ERR_OK; @@ -309,8 +315,10 @@ ModuleReturn ModuleManager::DeleteModule(Module *m) if (dlclose(handle)) Log() << dlerror(); +#ifdef _WIN32 if (!filename.empty()) unlink(filename.c_str()); +#endif return MOD_ERR_OK; } |