Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2005-10-05 01:53:40 UTC
Modified files:
ChangeLog include/class.h ircd/class.c
Log message:
Do not leak connection class structures after they are removed from ircd.conf.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.717 ircu2.10/ChangeLog:1.718
--- ircu2.10/ChangeLog:1.717 Sat Oct 1 14:07:07 2005
+++ ircu2.10/ChangeLog Tue Oct 4 18:53:30 2005
@@ -1,3 +1,16 @@
+2005-10-04 Michael Poole <[EMAIL PROTECTED]>
+ [Based on a patch by Jukka Ollila]
+
+ * include/class.h (find_class): Rename to do_find_class().
+
+ * ircd/class.c (class_delete_marked): Keep invalid classes in list
+ until next rehash.
+ (add_class): Use new parameter to do_find_class() to allow a class
+ to be "resurrected".
+ (find_class): Rename.
+ (report_classes): Use 'y' instead of 'Y' when reporting invalid
+ classes.
+
2005-10-01 Michael Poole <[EMAIL PROTECTED]>
* ircd/m_kick.c (m_kick): Remove gratuitous CheckDelayedJoins().
Index: ircu2.10/include/class.h
diff -u ircu2.10/include/class.h:1.20 ircu2.10/include/class.h:1.21
--- ircu2.10/include/class.h:1.20 Mon May 30 14:07:33 2005
+++ ircu2.10/include/class.h Tue Oct 4 18:53:30 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Declarations and interfaces for handling connection classes.
- * @version $Id: class.h,v 1.20 2005/05/30 21:07:33 entrope Exp $
+ * @version $Id: class.h,v 1.21 2005/10/05 01:53:30 entrope Exp $
*/
#ifndef INCLUDED_class_h
#define INCLUDED_class_h
@@ -86,6 +86,8 @@
#define ConfLinks(x) ((x)->conn_class->ref_count)
/** Get default usermode for ConfItem \a x. */
#define ConfUmode(x) ((x)->conn_class->default_umode)
+/** Find a valid configuration class by name. */
+#define find_class(name) do_find_class((name), 0)
/*
* Proto types
@@ -97,7 +99,7 @@
extern void class_mark_delete(void);
extern void class_delete_marked(void);
-extern struct ConnectionClass *find_class(const char *name);
+extern struct ConnectionClass *do_find_class(const char *name, int extras);
extern struct ConnectionClass *make_class(void);
extern void free_class(struct ConnectionClass * tmp);
extern char *get_conf_class(const struct ConfItem *aconf);
Index: ircu2.10/ircd/class.c
diff -u ircu2.10/ircd/class.c:1.35 ircu2.10/ircd/class.c:1.36
--- ircu2.10/ircd/class.c:1.35 Sat Oct 1 07:57:17 2005
+++ ircu2.10/ircd/class.c Tue Oct 4 18:53:30 2005
@@ -18,7 +18,7 @@
*/
/** @file
* @brief Implementation of connection class handling functions.
- * @version $Id: class.c,v 1.35 2005/10/01 14:57:17 entrope Exp $
+ * @version $Id: class.c,v 1.36 2005/10/05 01:53:30 entrope Exp $
*/
#include "config.h"
@@ -136,13 +136,12 @@
/*
* unlink marked classes, delete unreferenced ones
*/
- if (cl->valid)
+ if (cl->valid || Links(cl) > 1)
prev = cl;
else
{
prev->next = cl->next;
- if (0 == --cl->ref_count)
- free_class(cl);
+ free_class(cl);
}
}
}
@@ -215,7 +214,7 @@
Debug((DEBUG_DEBUG, "Add Class %s: cf: %u pf: %u ml: %u sq: %d",
name, confreq, ping, maxli, sendq));
assert(name != NULL);
- p = find_class(name);
+ p = do_find_class(name, 1);
if (!p)
p = make_class();
else
@@ -231,13 +230,16 @@
/** Find a connection class by name.
* @param[in] name Name of connection class to search for.
+ * @param[in] extras If non-zero, include unreferenced classes.
* @return Pointer to connection class structure (or NULL if none match).
*/
-struct ConnectionClass* find_class(const char *name)
+struct ConnectionClass* do_find_class(const char *name, int extras)
{
struct ConnectionClass *cltmp;
for (cltmp = connClassList; cltmp; cltmp = cltmp->next) {
+ if (!cltmp->valid || !extras)
+ continue;
if (!ircd_strcmp(ConClass(cltmp), name))
return cltmp;
}
@@ -256,9 +258,9 @@
struct ConnectionClass *cltmp;
for (cltmp = connClassList; cltmp; cltmp = cltmp->next)
- send_reply(sptr, RPL_STATSYLINE, 'Y', ConClass(cltmp), PingFreq(cltmp),
- ConFreq(cltmp), MaxLinks(cltmp), MaxSendq(cltmp),
- Links(cltmp) - 1);
+ send_reply(sptr, RPL_STATSYLINE, (cltmp->valid ? 'Y' : 'y'),
+ ConClass(cltmp), PingFreq(cltmp), ConFreq(cltmp),
+ MaxLinks(cltmp), MaxSendq(cltmp), Links(cltmp) - 1);
}
/** Return maximum SendQ length for a client.
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches