+2002-07-01 Andrew Miller <a1kmm@mware.virtualave.net>
+ * include/ircd_alloc.h (MyFree): Accept NULL pointers to do nothing
+ with, this is used quite a lot.
+ * ircd/class.c (make_class): Initialise the ref_count to 1 so that
+ we don't leak.
+ * ircd/class.c (add_class): When updating a class, free the old name
+ first to prevent leakage.
+ * ircd/class.c (class_delete_marked): Decrement the ref_count for the
+ class after it is removed from the linked list.
+ * ircd/ircd_parser.y: Changed a free to MyFree().
+ * ircd/ircd_parser.y: Removed a few debugging messages.
+
2002-07-01 Andrew Miller <a1kmm@mware.virtualave.net>
* s_bsd.c (read_packet): Our daily addition to the list of entities to
treat as servers - Connecting servers.
struct ConnectionClass *tmp;
tmp = (struct ConnectionClass*) MyMalloc(sizeof(struct ConnectionClass));
+ tmp->ref_count = 1;
assert(0 != tmp);
++connClassAllocCount;
return tmp;
void free_class(struct ConnectionClass* p)
{
- if (p) {
+ if (p)
+ {
assert(0 == p->valid);
if (p->cc_name)
- MyFree(p->cc_name);
+ MyFree(p->cc_name);
MyFree(p);
--connClassAllocCount;
}
*/
if (cl->valid)
prev = cl;
- else {
+ else
+ {
prev->next = cl->next;
- if (0 == cl->ref_count)
+ if (0 == --cl->ref_count)
free_class(cl);
}
}
t->next = p;
}
else
+ {
+ if (ConClass(t) != NULL)
+ MyFree(ConClass(t));
p = t;
+ }
Debug((DEBUG_DEBUG, "Add Class %s: cf: %u pf: %u ml: %u sq: %d",
name, confreq, ping, maxli, sendq));
ConClass(p) = name;
admincontact: CONTACT '=' QSTRING ';'
{
if (localConf.contact != NULL)
- free(localConf.contact);
+ MyFree(localConf.contact);
DupString(localConf.contact, yylval.text);
};
classblock: CLASS {
- name = NULL;
- tping = 90;
- tconn = 0;
- maxlinks = 0;
- sendq = 0;
+ name = NULL;
+ tping = 90;
+ tconn = 0;
+ maxlinks = 0;
+ sendq = 0;
} '{' classitems '}'
{
- if (name != NULL)
- {
- add_class(name, tping, tconn, maxlinks, sendq);
- }
+ if (name != NULL)
+ {
+ add_class(name, tping, tconn, maxlinks, sendq);
+ }
} ';';
classitems: classitem classitems | classitem;
classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
classsendq;
classname: NAME '=' QSTRING ';'
{
- MyFree(name);
- DupString(name, yylval.text);
+ MyFree(name);
+ DupString(name, yylval.text);
};
classpingfreq: PINGFREQ '=' timespec ';'
{
- tping = yylval.num;
+ tping = yylval.num;
};
classconnfreq: CONNECTFREQ '=' timespec ';'
{
- tconn = yylval.num;
+ tconn = yylval.num;
};
classmaxlinks: MAXLINKS '=' expr ';'
{
- maxlinks = yylval.num;
+ maxlinks = yylval.num;
};
classsendq: SENDQ '=' sizespec ';'
{
- sendq = yylval.num;
+ sendq = yylval.num;
};
connectblock: CONNECT
/*ccount < MAXCONFLINKS &&*/ !strchr(host, '*') &&
!strchr(host, '?'))
{
- aconf = MyMalloc(sizeof(*aconf));
- aconf->status = CONF_SERVER;
- aconf->name = name;
- aconf->passwd = pass;
- aconf->conn_class = class;
- aconf->port = port;
- aconf->status = CONF_SERVER;
- aconf->host = host;
- aconf->next = GlobalConfList;
- aconf->ipnum.s_addr = INADDR_NONE;
- lookup_confhost(aconf);
- GlobalConfList = aconf;
- printf("Server added: %s\n", name);
- /* ccount++; -- XXX fixme --- A1kmm */
+ aconf = make_conf();
+ aconf->status = CONF_SERVER;
+ aconf->name = name;
+ aconf->passwd = pass;
+ aconf->conn_class = class;
+ aconf->port = port;
+ aconf->status = CONF_SERVER;
+ aconf->host = host;
+ aconf->next = GlobalConfList;
+ aconf->ipnum.s_addr = INADDR_NONE;
+ lookup_confhost(aconf);
+ GlobalConfList = aconf;
}
else
{
- MyFree(name);
- MyFree(pass);
- MyFree(host);
- name = pass = host = NULL;
+ MyFree(name);
+ MyFree(pass);
+ MyFree(host);
+ name = pass = host = NULL;
}
}';';
connectitems: connectitem connectitems | connectitem;
{
if (aconf->name != NULL && aconf->passwd != NULL && aconf->host != NULL)
{
- log_write(LS_CONFIG, L_ERROR, 0, "added an oper block for host %s", aconf->host);
aconf->next = GlobalConfList;
GlobalConfList = aconf;
}