diff options
author | geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2007-08-29 19:05:59 +0000 |
---|---|---|
committer | geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2007-08-29 19:05:59 +0000 |
commit | 3c1a2fbfca39b47e2f6df7862e7c83fe9f49f1c9 (patch) | |
tree | 1ca88f21a4d173027a66a7433a38b29202ff958e | |
parent | 56800d410333084d3b8e527bc91422aab7e19477 (diff) |
BUILD : 1.7.19 (1289) BUGS : 768 NOTES : Fixed module runtime directory not always being cleaned up nicely
git-svn-id: svn://svn.anope.org/anope/trunk@1289 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1007 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | Changes | 3 | ||||
-rw-r--r-- | include/extern.h | 2 | ||||
-rw-r--r-- | include/services.h | 4 | ||||
-rw-r--r-- | src/list.c | 10 | ||||
-rw-r--r-- | src/log.c | 9 | ||||
-rw-r--r-- | src/main.c | 8 | ||||
-rw-r--r-- | src/modules.c | 104 | ||||
-rw-r--r-- | version.log | 6 |
8 files changed, 130 insertions, 16 deletions
@@ -31,6 +31,9 @@ Anope Version S V N 08/29 F OperServ SGLINE ADD now strips a trailing space from the mask. [#761] 08/29 F TS6 UID generation for all supported TS6 IRCDs. [#731] +Provided by Trystan <trystan@nomadirc.net> - 2007 +08/29 F Module runtime directory not always properly cleaned up. [#768] + Provided by nenolod <nenolod@nenolod.net> - 2007 08/29 F TS6 UID generation for Charybdis. [#731] diff --git a/include/extern.h b/include/extern.h index 934c69d45..fcc1590fc 100644 --- a/include/extern.h +++ b/include/extern.h @@ -30,7 +30,7 @@ #include "slist.h" - +E void ModuleRunTimeDirCleanUp(void); E char *uplink; diff --git a/include/services.h b/include/services.h index 4507e2b4a..169b995aa 100644 --- a/include/services.h +++ b/include/services.h @@ -109,6 +109,10 @@ #endif #endif +#ifndef _WIN32 +#include <dirent.h> +#endif + #ifdef USE_RDB # define MAX_SQL_BUF 4096 #endif diff --git a/src/list.c b/src/list.c index 3bb9be8fa..17bbaf74c 100644 --- a/src/list.c +++ b/src/list.c @@ -83,10 +83,13 @@ are given, detailed information about those nicks is displayed.\n\ if (chdir(services_dir) < 0) { fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno)); + ModuleRunTimeDirCleanUp(); exit(1); } - if (!read_config(0)) + if (!read_config(0)) { + ModuleRunTimeDirCleanUp(); exit(1); + } load_ns_dbase(); lang_init(); @@ -169,10 +172,13 @@ are given, detailed information about those channels is displayed.\n\ if (chdir(services_dir) < 0) { fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno)); + ModuleRunTimeDirCleanUp(); exit(1); } - if (!read_config(0)) + if (!read_config(0)) { + ModuleRunTimeDirCleanUp(); exit(1); + } load_ns_dbase(); load_cs_dbase(); @@ -247,6 +247,9 @@ void fatal(const char *fmt, ...) if (servsock >= 0) anope_cmd_global(NULL, "FATAL ERROR! %s", buf2); + /* one of the many places this needs to be called from */ + ModuleRunTimeDirCleanUp(); + exit(1); } @@ -283,6 +286,9 @@ void fatal_perror(const char *fmt, ...) anope_cmd_global(NULL, "FATAL ERROR! %s: %s", buf2, strerror(errno_save)); + /* one of the many places this needs to be called from */ + ModuleRunTimeDirCleanUp(); + exit(1); } @@ -323,5 +329,8 @@ void fatal_sockerror(const char *fmt, ...) anope_cmd_global(NULL, "FATAL ERROR! %s: %s", buf2, strerror(errno_save)); + /* one of the many places this needs to be called from */ + ModuleRunTimeDirCleanUp(); + exit(1); } diff --git a/src/main.c b/src/main.c index 081b6ad00..ff0af6a01 100644 --- a/src/main.c +++ b/src/main.c @@ -309,6 +309,8 @@ static void services_shutdown(void) /* First don't unload protocol module, then do so */ modules_unload_all(true, false); modules_unload_all(true, true); + /* just in case they weren't all removed at least run once */ + ModuleRunTimeDirCleanUp(); } /*************************************************************************/ @@ -567,6 +569,9 @@ int main(int ac, char **av, char **envp) #endif { do_listnicks(ac, av); + modules_unload_all(1, 0); + modules_unload_all(1, 1); + ModuleRunTimeDirCleanUp(); return 0; } #ifdef _WIN32 @@ -576,6 +581,9 @@ int main(int ac, char **av, char **envp) #endif { do_listchans(ac, av); + modules_unload_all(1, 0); + modules_unload_all(1, 1); + ModuleRunTimeDirCleanUp(); return 0; } diff --git a/src/modules.c b/src/modules.c index bdeb179f3..5843168e7 100644 --- a/src/modules.c +++ b/src/modules.c @@ -626,20 +626,20 @@ int loadModule(Module * m, User * u) return MOD_ERR_NOLOAD; } if (func) { - version = (int (*)())ano_modsym(m->handle,"getAnopeBuildVersion");
- if (version) {
- if (version() >= VERSION_BUILD ) {
- if(debug) {
- alog("Module %s compiled against current or newer anope revision %d, this is %d",m->name,version(),VERSION_BUILD);
- }
- } else {
+ version = (int (*)())ano_modsym(m->handle,"getAnopeBuildVersion"); + if (version) { + if (version() >= VERSION_BUILD ) { + if(debug) { + alog("Module %s compiled against current or newer anope revision %d, this is %d",m->name,version(),VERSION_BUILD); + } + } else { alog("Module %s is compiled against an old version of anope (%d) current is %d", m->name, version(), VERSION_BUILD); alog("Rebuild module %s against the current version to resolve this error", m->name); - ano_modclose(m->handle);
- ano_modclearerr();
- return MOD_ERR_NOLOAD;
- }
- } else {
+ ano_modclose(m->handle); + ano_modclearerr(); + return MOD_ERR_NOLOAD; + } + } else { ano_modclose(m->handle); ano_modclearerr(); alog("Module %s is compiled against an older version of anope (unknown)", m->name); @@ -2788,4 +2788,84 @@ void handleModuleOperationQueue(void) mod_current_user = NULL; } +void ModuleRunTimeDirCleanUp(void) +{ +#ifndef _WIN32 + DIR *dirp; + struct dirent *dp; +#else + BOOL fFinished; + HANDLE hList; + TCHAR szDir[MAX_PATH + 1]; + TCHAR szSubDir[MAX_PATH + 1]; + WIN32_FIND_DATA FileData; + char buffer[_MAX_PATH]; +#endif + char dirbuf[BUFSIZE]; + char filebuf[BUFSIZE]; + + +#ifndef _WIN32 + snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir); +#else + snprintf(dirbuf, BUFSIZE, "\\%s", "modules/runtime"); +#endif + + if (debug) { + alog("debug: Cleaning out Module run time directory (%s) - this may take a moment please wait", dirbuf); + } + +#ifndef _WIN32 + if ((dirp = opendir(dirbuf)) == NULL) { + if (debug) { + alog("debug: cannot open directory (%s)", dirbuf); + } + return; + } + while ((dp = readdir(dirp)) != NULL) { + if (dp->d_ino == 0) { + continue; + } + if (!stricmp(dp->d_name, ".") || !stricmp(dp->d_name, "..")) { + continue; + } + snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, dp->d_name); + unlink(filebuf); + } + closedir(dirp); +#else + /* Get the current working directory: */ + if (_getcwd(buffer, _MAX_PATH) == NULL) { + if (debug) { + alog("debug: Unable to set Current working directory"); + } + } + snprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirname); + + hList = FindFirstFile(szDir, &FileData); + if (hList != INVALID_HANDLE_VALUE) { + fFinished = FALSE; + while (!fFinished) { + if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { + snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, FileData.cFileName); + DeleteFile(filebuf); + } + if (!FindNextFile(hList, &FileData)) { + if (GetLastError() == ERROR_NO_MORE_FILES) { + fFinished = TRUE; + } + } + } + } else { + if (debug) { + alog("debug: Invalid File Handle. GetLastError reports %d\n", GetLastError()); + } + } + FindClose(hList); +#endif + if (debug) { + alog("debug: Module run time directory has been cleaned out"); + } +} + /* EOF */ diff --git a/version.log b/version.log index a2901d762..8aa1f6c68 100644 --- a/version.log +++ b/version.log @@ -9,10 +9,14 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="19" VERSION_EXTRA="-svn" -VERSION_BUILD="1288" +VERSION_BUILD="1289" # $Log$ # +# BUILD : 1.7.19 (1289) +# BUGS : 768 +# NOTES : Fixed module runtime directory not always being cleaned up nicely +# # BUILD : 1.7.19 (1288) # BUGS : 761 # NOTES : Fixing up a comment from the last commit |