From f2a2fa77c87bd4eb49f2bc54a0b02e14874322c8 Mon Sep 17 00:00:00 2001 From: codemastr Date: Sun, 7 Dec 2003 04:58:39 +0000 Subject: [PATCH] New module rehash system fixes --- Changes | 2 ++ src/modules.c | 5 +++++ src/support.c | 14 +++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 24d20a29c..2c5306127 100644 --- a/Changes +++ b/Changes @@ -2615,3 +2615,5 @@ seen. gmtime warning still there after a newer version has been compiled. This also fixes the problem with hooks disappearing during a rehash (#0001332) reported by AngryWolf and (#0001325) reported by Cnils. This might need some testing. +- Fixed some problems with the copyfile routine for the new module rehash system and also fixed + an issue with rehashing when permanent modules are loaded diff --git a/src/modules.c b/src/modules.c index ee492d61a..15e433503 100644 --- a/src/modules.c +++ b/src/modules.c @@ -162,11 +162,13 @@ char *Module_Create(char *path_) if (!mod_header) { irc_dlclose(Mod); + remove(tmppath); return ("Unable to locate Mod_Header"); } if (!mod_header->modversion) { irc_dlclose(Mod); + remove(tmppath); return ("Lacking mod_header->modversion"); } if (sscanf(mod_header->modversion, "3.2-b%d-%d", &betaversion, &tag)) { @@ -174,6 +176,7 @@ char *Module_Create(char *path_) snprintf(errorbuf, 1023, "Unsupported version, we support %s, %s is %s", MOD_WE_SUPPORT, path, mod_header->modversion); irc_dlclose(Mod); + remove(tmppath); return(errorbuf); } } @@ -181,11 +184,13 @@ char *Module_Create(char *path_) !mod_header->description) { irc_dlclose(Mod); + remove(tmppath); return("Lacking sane header pointer"); } if (Module_Find(mod_header->name)) { irc_dlclose(Mod); + remove(tmppath); return (NULL); } mod = (Module *)Module_make(mod_header, Mod); diff --git a/src/support.c b/src/support.c index 6c5827dd7..7ce319751 100644 --- a/src/support.c +++ b/src/support.c @@ -1733,12 +1733,20 @@ void unreal_copyfile(char *src, char *dest) { char buf[2048]; int srcfd = open(src, O_RDONLY); - int destfd = open(dest, O_WRONLY|O_CREAT, S_IRUSR|S_IXUSR); + int destfd; int len; + if (srcfd < 1) + return; + + destfd = open(dest, O_WRONLY|O_CREAT, S_IRUSR|S_IXUSR); + + if (destfd < 1) + return; + while ((len = read(srcfd, buf, 1023)) > 0) write(destfd, buf, len); - close(src); - close(dest); + close(srcfd); + close(destfd); }