From 26068b5fa146a7b18697dd9e0dd73e7c750448ff Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sun, 21 Aug 2005 13:46:08 +0000 Subject: [PATCH] Fix bugs in rehashing pseudo commands and in kill handling. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1462 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 12 ++++++++++++ include/s_conf.h | 1 + ircd/ircd_parser.y | 11 +---------- ircd/m_kill.c | 2 +- ircd/s_conf.c | 30 ++++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a24d168..fd931fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-08-21 Michael Poole + + * include/s_conf.h (free_mapping): Declare new function. + + * ircd/ircd_parser.y (pseudoblock): Use it. + + * ircd/s_conf.c (free_mapping): Define it. + (close_mappings): New function. + (rehash): Call close_mappings() before reading file. + + * ircd/m_kill.c (do_kill): Revert 2005-08-18 change. + 2005-08-19 Michael Poole * ircd/parse.c (tok_tree): Re-add token tree structure. diff --git a/include/s_conf.h b/include/s_conf.h index 0907f9b..301e9ab 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -186,6 +186,7 @@ extern const char *find_quarantine(const char* chname); extern void lookup_confhost(struct ConfItem *aconf); extern void conf_parse_userhost(struct ConfItem *aconf, char *host); extern struct ConfItem *conf_debug_iline(const char *client); +extern void free_mapping(struct s_map *smap); extern void yyerror(const char *msg); diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index 2ce1b6c..934f923 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -959,16 +959,7 @@ pseudoitems '}' ';' } else { - struct nick_host *nh, *next; - for (nh = smap->services; nh; nh = next) - { - next = nh->next; - MyFree(nh); - } - MyFree(smap->name); - MyFree(smap->command); - MyFree(smap->prepend); - MyFree(smap); + free_mapping(smap); } smap = NULL; }; diff --git a/ircd/m_kill.c b/ircd/m_kill.c index d90ffe7..9c4f0e0 100644 --- a/ircd/m_kill.c +++ b/ircd/m_kill.c @@ -155,7 +155,7 @@ static int do_kill(struct Client* cptr, struct Client* sptr, victim, "%C :%s %s", victim, feature_bool(FEAT_HIS_KILLWHO) ? feature_str(FEAT_HIS_SERVERNAME) : cli_name(sptr), msg); return exit_client_msg(cptr, victim, feature_bool(FEAT_HIS_KILLWHO) - ? &his : sptr, "Killed (%s %s)", + ? &me : sptr, "Killed (%s %s)", feature_bool(FEAT_HIS_KILLWHO) ? feature_str(FEAT_HIS_SERVERNAME) : cli_name(sptr), msg); diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 21e1018..14328f6 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -876,6 +876,35 @@ attach_conf_uworld(struct Client *cptr) attach_conf_uworld(lp->value.cptr); } +/** Free all memory associated with service mapping \a smap. + * @param smap[in] The mapping to free. + */ +void free_mapping(struct s_map *smap) +{ + struct nick_host *nh, *next; + for (nh = smap->services; nh; nh = next) + { + next = nh->next; + MyFree(nh); + } + MyFree(smap->name); + MyFree(smap->command); + MyFree(smap->prepend); + MyFree(smap); +} + +/** Unregister and free all current service mappings. */ +static void close_mappings(void) +{ + struct s_map *map, *next; + + for (map = GlobalServiceMapList; map; map = next) { + next = map->next; + unregister_mapping(map); + free_mapping(map); + } +} + /** Reload the configuration file. * @param cptr Client that requested rehash (if a signal, &me). * @param sig Type of rehash (0 = oper-requested, 1 = signal, 2 = @@ -934,6 +963,7 @@ int rehash(struct Client *cptr, int sig) class_mark_delete(); mark_listeners_closing(); iauth_mark_closing(); + close_mappings(); read_configuration_file(); -- 2.20.1