This commit is contained in:
William Pitcock 2008-04-01 19:51:12 -05:00
commit 2b2e97af7f
11 changed files with 343 additions and 326 deletions

View File

@ -1,50 +1,51 @@
/* $Id: cache.h 6 2005-09-10 01:02:21Z nenolod $ */ /* $Id: cache.h 24250 2007-08-22 19:15:08Z androsyn $ */
#ifndef INCLUDED_CACHE_H #ifndef INCLUDED_CACHE_H
#define INCLUDED_CACHE_H #define INCLUDED_CACHE_H
#include "client.h" #define HELP_MAX 100
#define HELP_MAX 100 #define CACHELINELEN 81
#define CACHEFILELEN 30
#define CACHELINELEN 81 /* two servernames, a gecos, three spaces, ":1", '\0' */
#define CACHEFILELEN 30 #define LINKSLINELEN (HOSTLEN + HOSTLEN + REALLEN + 6)
#define HELP_USER 0x001 #define HELP_USER 0x001
#define HELP_OPER 0x002 #define HELP_OPER 0x002
struct Client; struct Client;
struct cachefile struct cachefile
{ {
char name[CACHEFILELEN]; char name[CACHEFILELEN];
rb_dlink_list contents; rb_dlink_list contents;
int flags; int flags;
}; };
struct cacheline struct cacheline
{ {
char data[CACHELINELEN]; char data[CACHELINELEN];
rb_dlink_node linenode; rb_dlink_node linenode;
}; };
extern struct cachefile *user_motd; extern struct cachefile *user_motd;
extern struct cachefile *oper_motd; extern struct cachefile *oper_motd;
extern struct cacheline *emptyline; extern struct cacheline *emptyline;
extern char user_motd_changed[MAX_DATE_STRING]; extern char user_motd_changed[MAX_DATE_STRING];
extern rb_dlink_list links_cache_list;
extern void init_cache(void);
extern struct cachefile *cache_file(const char *, const char *, int); void init_cache(void);
extern void free_cachefile(struct cachefile *); struct cachefile *cache_file(const char *, const char *, int);
void cache_links(void *unused);
extern void load_help(void); void free_cachefile(struct cachefile *);
extern void send_user_motd(struct Client *); void load_help(void);
extern void send_oper_motd(struct Client *);
void send_user_motd(struct Client *);
void cache_user_motd(void);
struct Dictionary; struct Dictionary;
extern struct Dictionary *help_dict_oper; extern struct Dictionary *help_dict_oper;
extern struct Dictionary *help_dict_user; extern struct Dictionary *help_dict_user;
#endif #endif

View File

@ -10,7 +10,7 @@
#ifndef INCLUDED_monitor_h #ifndef INCLUDED_monitor_h
#define INCLUDED_monitor_h #define INCLUDED_monitor_h
struct BlockHeap; struct rb_bh;
struct monitor struct monitor
{ {

View File

@ -394,13 +394,13 @@ rb_bh_free(rb_bh * bh, void *ptr)
if(unlikely(bh == NULL)) if(unlikely(bh == NULL))
{ {
rb_lib_log("balloc.c:rb_bhFree() bh == NULL"); rb_lib_log("balloc.c:rb_bh_free() bh == NULL");
return (1); return (1);
} }
if(unlikely(ptr == NULL)) if(unlikely(ptr == NULL))
{ {
rb_lib_log("balloc.rb_bhFree() ptr == NULL"); rb_lib_log("balloc.rb_bh_free() ptr == NULL");
return (1); return (1);
} }

View File

@ -1,37 +1,37 @@
/* /*
* ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd). * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd).
* cache.c - code for caching files * cache.c - code for caching files
* *
* Copyright (C) 2003 Lee Hardy <lee@leeh.co.uk> * Copyright (C) 2003 Lee Hardy <lee@leeh.co.uk>
* Copyright (C) 2003-2005 ircd-ratbox development team * Copyright (C) 2003-2005 ircd-ratbox development team
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
* met: * met:
* *
* 1.Redistributions of source code must retain the above copyright notice, * 1.Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2.Redistributions in binary form must reproduce the above copyright * 2.Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3.The name of the author may not be used to endorse or promote products * 3.The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: cache.c 3436 2007-05-02 19:56:40Z jilles $ * $Id: cache.c 25119 2008-03-13 16:57:05Z androsyn $
*/ */
#include "stdinc.h" #include "stdinc.h"
#include "ircd_defs.h" #include "ircd_defs.h"
#include "common.h" #include "common.h"
@ -41,121 +41,145 @@
#include "cache.h" #include "cache.h"
#include "sprintf_irc.h" #include "sprintf_irc.h"
#include "irc_dictionary.h" #include "irc_dictionary.h"
#include "numeric.h" #include "numeric.h"
static BlockHeap *cachefile_heap = NULL; struct cachefile *user_motd = NULL;
static BlockHeap *cacheline_heap = NULL; struct cachefile *oper_motd = NULL;
struct cacheline *emptyline = NULL;
struct cachefile *user_motd = NULL; rb_dlink_list links_cache_list;
struct cachefile *oper_motd = NULL; char user_motd_changed[MAX_DATE_STRING];
char user_motd_changed[MAX_DATE_STRING];
struct Dictionary *help_dict_oper = NULL; struct Dictionary *help_dict_oper = NULL;
struct Dictionary *help_dict_user = NULL; struct Dictionary *help_dict_user = NULL;
/* init_cache() /* init_cache()
* *
* inputs - * inputs -
* outputs - * outputs -
* side effects - inits the file/line cache blockheaps, loads motds * side effects - inits the file/line cache blockheaps, loads motds
*/ */
void void
init_cache(void) init_cache(void)
{ {
cachefile_heap = BlockHeapCreate(sizeof(struct cachefile), CACHEFILE_HEAP_SIZE); /* allocate the emptyline */
cacheline_heap = BlockHeapCreate(sizeof(struct cacheline), CACHELINE_HEAP_SIZE); emptyline = rb_malloc(sizeof(struct cacheline));
emptyline->data[0] = ' ';
user_motd_changed[0] = '\0'; emptyline->data[1] = '\0';
user_motd_changed[0] = '\0';
user_motd = cache_file(MPATH, "ircd.motd", 0);
oper_motd = cache_file(OPATH, "opers.motd", 0); user_motd = cache_file(MPATH, "ircd.motd", 0);
oper_motd = cache_file(OPATH, "opers.motd", 0);
memset(&links_cache_list, 0, sizeof(links_cache_list));
help_dict_oper = irc_dictionary_create(strcasecmp); help_dict_oper = irc_dictionary_create(strcasecmp);
help_dict_user = irc_dictionary_create(strcasecmp); help_dict_user = irc_dictionary_create(strcasecmp);
} }
/* cache_file() /* cache_file()
* *
* inputs - file to cache, files "shortname", flags to set * inputs - file to cache, files "shortname", flags to set
* outputs - pointer to file cached, else NULL * outputs - pointer to file cached, else NULL
* side effects - * side effects -
*/ */
struct cachefile * struct cachefile *
cache_file(const char *filename, const char *shortname, int flags) cache_file(const char *filename, const char *shortname, int flags)
{ {
FILE *in; FILE *in;
struct cachefile *cacheptr; struct cachefile *cacheptr;
struct cacheline *lineptr; struct cacheline *lineptr;
char line[BUFSIZE]; char line[BUFSIZE];
char *p; char *p;
if((in = fopen(filename, "r")) == NULL) if((in = fopen(filename, "r")) == NULL)
return NULL; return NULL;
if(strcmp(shortname, "ircd.motd") == 0)
{ cacheptr = rb_malloc(sizeof(struct cachefile));
struct stat sb;
struct tm *local_tm; rb_strlcpy(cacheptr->name, shortname, sizeof(cacheptr->name));
cacheptr->flags = flags;
if(fstat(fileno(in), &sb) < 0)
return NULL; /* cache the file... */
while(fgets(line, sizeof(line), in) != NULL)
local_tm = localtime(&sb.st_mtime); {
if((p = strpbrk(line, "\r\n")) != NULL)
if(local_tm != NULL) *p = '\0';
rb_snprintf(user_motd_changed, sizeof(user_motd_changed),
"%d/%d/%d %d:%d", if(!EmptyString(line))
local_tm->tm_mday, local_tm->tm_mon + 1, {
1900 + local_tm->tm_year, local_tm->tm_hour, lineptr = rb_malloc(sizeof(struct cacheline));
local_tm->tm_min); rb_strlcpy(lineptr->data, line, sizeof(lineptr->data));
} rb_dlinkAddTail(lineptr, &lineptr->linenode, &cacheptr->contents);
}
cacheptr = BlockHeapAlloc(cachefile_heap); else
rb_dlinkAddTailAlloc(emptyline, &cacheptr->contents);
strlcpy(cacheptr->name, shortname, sizeof(cacheptr->name)); }
cacheptr->flags = flags;
fclose(in);
/* cache the file... */ return cacheptr;
while(fgets(line, sizeof(line), in) != NULL) }
{
if((p = strchr(line, '\n')) != NULL) void
*p = '\0'; cache_links(void *unused)
{
lineptr = BlockHeapAlloc(cacheline_heap); struct Client *target_p;
if(EmptyString(line)) rb_dlink_node *ptr;
strlcpy(lineptr->data, " ", sizeof(lineptr->data)); rb_dlink_node *next_ptr;
else char *links_line;
strlcpy(lineptr->data, line, sizeof(lineptr->data));
rb_dlinkAddTail(lineptr, &lineptr->linenode, &cacheptr->contents); RB_DLINK_FOREACH_SAFE(ptr, next_ptr, links_cache_list.head)
} {
rb_free(ptr->data);
fclose(in); rb_free_rb_dlink_node(ptr);
return cacheptr; }
}
links_cache_list.head = links_cache_list.tail = NULL;
/* free_cachefile() links_cache_list.length = 0;
*
* inputs - cachefile to free RB_DLINK_FOREACH(ptr, global_serv_list.head)
* outputs - {
* side effects - cachefile and its data is free'd target_p = ptr->data;
*/
void /* skip ourselves (done in /links) and hidden servers */
free_cachefile(struct cachefile *cacheptr) if(IsMe(target_p) ||
{ (IsHidden(target_p) && !ConfigServerHide.disable_hidden))
rb_dlink_node *ptr; continue;
rb_dlink_node *next_ptr;
/* if the below is ever modified, change LINKSLINELEN */
if(cacheptr == NULL) links_line = rb_malloc(LINKSLINELEN);
return; rb_snprintf(links_line, LINKSLINELEN, "%s %s :1 %s",
target_p->name, me.name,
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, cacheptr->contents.head) target_p->info[0] ? target_p->info :
{ "(Unknown Location)");
BlockHeapFree(cacheline_heap, ptr->data);
} rb_dlinkAddTailAlloc(links_line, &links_cache_list);
}
BlockHeapFree(cachefile_heap, cacheptr); }
}
/* free_cachefile()
*
* inputs - cachefile to free
* outputs -
* side effects - cachefile and its data is free'd
*/
void
free_cachefile(struct cachefile *cacheptr)
{
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
if(cacheptr == NULL)
return;
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, cacheptr->contents.head)
{
if(ptr->data != emptyline)
rb_free(ptr->data);
}
rb_free(cacheptr);
}
/* load_help() /* load_help()
* *
* inputs - * inputs -
@ -210,65 +234,57 @@ load_help(void)
} }
closedir(helpfile_dir); closedir(helpfile_dir);
} }
/* send_user_motd() /* send_user_motd()
* *
* inputs - client to send motd to * inputs - client to send motd to
* outputs - client is sent motd if exists, else ERR_NOMOTD * outputs - client is sent motd if exists, else ERR_NOMOTD
* side effects - * side effects -
*/ */
void void
send_user_motd(struct Client *source_p) send_user_motd(struct Client *source_p)
{ {
struct cacheline *lineptr; struct cacheline *lineptr;
rb_dlink_node *ptr; rb_dlink_node *ptr;
const char *myname = get_id(&me, source_p); const char *myname = get_id(&me, source_p);
const char *nick = get_id(source_p, source_p); const char *nick = get_id(source_p, source_p);
if(user_motd == NULL || rb_dlink_list_length(&user_motd->contents) == 0)
if(user_motd == NULL || rb_dlink_list_length(&user_motd->contents) == 0) {
{ sendto_one(source_p, form_str(ERR_NOMOTD), myname, nick);
sendto_one(source_p, form_str(ERR_NOMOTD), myname, nick); return;
return; }
}
sendto_one(source_p, form_str(RPL_MOTDSTART), myname, nick, me.name);
sendto_one(source_p, form_str(RPL_MOTDSTART), myname, nick, me.name);
RB_DLINK_FOREACH(ptr, user_motd->contents.head)
RB_DLINK_FOREACH(ptr, user_motd->contents.head) {
{ lineptr = ptr->data;
lineptr = ptr->data; sendto_one(source_p, form_str(RPL_MOTD), myname, nick, lineptr->data);
sendto_one(source_p, form_str(RPL_MOTD), myname, nick, lineptr->data); }
}
sendto_one(source_p, form_str(RPL_ENDOFMOTD), myname, nick);
sendto_one(source_p, form_str(RPL_ENDOFMOTD), myname, nick); }
}
void
/* send_oper_motd() cache_user_motd(void)
* {
* inputs - client to send motd to struct stat sb;
* outputs - client is sent oper motd if exists struct tm *local_tm;
* side effects -
*/ if(stat(MPATH, &sb) == 0)
void {
send_oper_motd(struct Client *source_p) local_tm = localtime(&sb.st_mtime);
{
struct cacheline *lineptr; if(local_tm != NULL)
rb_dlink_node *ptr; {
rb_snprintf(user_motd_changed, sizeof(user_motd_changed),
if(oper_motd == NULL || rb_dlink_list_length(&oper_motd->contents) == 0) "%d/%d/%d %d:%d",
return; local_tm->tm_mday, local_tm->tm_mon + 1,
1900 + local_tm->tm_year, local_tm->tm_hour,
sendto_one(source_p, form_str(RPL_OMOTDSTART), local_tm->tm_min);
me.name, source_p->name); }
}
RB_DLINK_FOREACH(ptr, oper_motd->contents.head) free_cachefile(user_motd);
{ user_motd = cache_file(MPATH, "ircd.motd", 0);
lineptr = ptr->data; }
sendto_one(source_p, form_str(RPL_OMOTD),
me.name, source_p->name, lineptr->data);
}
sendto_one(source_p, form_str(RPL_ENDOFOMOTD),
me.name, source_p->name);
}

View File

@ -45,10 +45,10 @@
extern rb_dlink_list global_channel_list; extern rb_dlink_list global_channel_list;
extern struct config_channel_entry ConfigChannel; extern struct config_channel_entry ConfigChannel;
extern BlockHeap *channel_heap; extern rb_bh *channel_heap;
extern BlockHeap *ban_heap; extern rb_bh *ban_heap;
extern BlockHeap *topic_heap; extern rb_bh *topic_heap;
extern BlockHeap *member_heap; extern rb_bh *member_heap;
static int channel_capabs[] = { CAP_EX, CAP_IE, static int channel_capabs[] = { CAP_EX, CAP_IE,
CAP_SERVICE, CAP_SERVICE,
@ -73,10 +73,10 @@ static int h_can_join;
void void
init_channels(void) init_channels(void)
{ {
channel_heap = BlockHeapCreate(sizeof(struct Channel), CHANNEL_HEAP_SIZE); channel_heap = rb_bh_create(sizeof(struct Channel), CHANNEL_HEAP_SIZE);
ban_heap = BlockHeapCreate(sizeof(struct Ban), BAN_HEAP_SIZE); ban_heap = rb_bh_create(sizeof(struct Ban), BAN_HEAP_SIZE);
topic_heap = BlockHeapCreate(TOPICLEN + 1 + USERHOST_REPLYLEN, TOPIC_HEAP_SIZE); topic_heap = rb_bh_create(TOPICLEN + 1 + USERHOST_REPLYLEN, TOPIC_HEAP_SIZE);
member_heap = BlockHeapCreate(sizeof(struct membership), MEMBER_HEAP_SIZE); member_heap = rb_bh_create(sizeof(struct membership), MEMBER_HEAP_SIZE);
h_can_join = register_hook("can_join"); h_can_join = register_hook("can_join");
} }
@ -88,7 +88,7 @@ struct Channel *
allocate_channel(const char *chname) allocate_channel(const char *chname)
{ {
struct Channel *chptr; struct Channel *chptr;
chptr = BlockHeapAlloc(channel_heap); chptr = rb_bh_alloc(channel_heap);
chptr->chname = rb_strdup(chname); chptr->chname = rb_strdup(chname);
return (chptr); return (chptr);
} }
@ -97,14 +97,14 @@ void
free_channel(struct Channel *chptr) free_channel(struct Channel *chptr)
{ {
rb_free(chptr->chname); rb_free(chptr->chname);
BlockHeapFree(channel_heap, chptr); rb_bh_free(channel_heap, chptr);
} }
struct Ban * struct Ban *
allocate_ban(const char *banstr, const char *who) allocate_ban(const char *banstr, const char *who)
{ {
struct Ban *bptr; struct Ban *bptr;
bptr = BlockHeapAlloc(ban_heap); bptr = rb_bh_alloc(ban_heap);
bptr->banstr = rb_strdup(banstr); bptr->banstr = rb_strdup(banstr);
bptr->who = rb_strdup(who); bptr->who = rb_strdup(who);
@ -116,7 +116,7 @@ free_ban(struct Ban *bptr)
{ {
rb_free(bptr->banstr); rb_free(bptr->banstr);
rb_free(bptr->who); rb_free(bptr->who);
BlockHeapFree(ban_heap, bptr); rb_bh_free(ban_heap, bptr);
} }
@ -205,7 +205,7 @@ add_user_to_channel(struct Channel *chptr, struct Client *client_p, int flags)
if(client_p->user == NULL) if(client_p->user == NULL)
return; return;
msptr = BlockHeapAlloc(member_heap); msptr = rb_bh_alloc(member_heap);
msptr->chptr = chptr; msptr->chptr = chptr;
msptr->client_p = client_p; msptr->client_p = client_p;
@ -247,7 +247,7 @@ remove_user_from_channel(struct membership *msptr)
if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0) if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0)
destroy_channel(chptr); destroy_channel(chptr);
BlockHeapFree(member_heap, msptr); rb_bh_free(member_heap, msptr);
return; return;
} }
@ -284,7 +284,7 @@ remove_user_from_channels(struct Client *client_p)
if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0) if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0)
destroy_channel(chptr); destroy_channel(chptr);
BlockHeapFree(member_heap, msptr); rb_bh_free(member_heap, msptr);
} }
client_p->user->channel.head = client_p->user->channel.tail = NULL; client_p->user->channel.head = client_p->user->channel.tail = NULL;
@ -1020,7 +1020,7 @@ allocate_topic(struct Channel *chptr)
if(chptr == NULL) if(chptr == NULL)
return; return;
ptr = BlockHeapAlloc(topic_heap); ptr = rb_bh_alloc(topic_heap);
/* Basically we allocate one large block for the topic and /* Basically we allocate one large block for the topic and
* the topic info. We then split it up into two and shove it * the topic info. We then split it up into two and shove it
@ -1050,7 +1050,7 @@ free_topic(struct Channel *chptr)
* MUST change this as well * MUST change this as well
*/ */
ptr = chptr->topic; ptr = chptr->topic;
BlockHeapFree(topic_heap, ptr); rb_bh_free(topic_heap, ptr);
chptr->topic = NULL; chptr->topic = NULL;
chptr->topic_info = NULL; chptr->topic_info = NULL;
} }

View File

@ -73,9 +73,9 @@ static int qs_server(struct Client *, struct Client *, struct Client *, const ch
static EVH check_pings; static EVH check_pings;
extern BlockHeap *client_heap; extern rb_bh *client_heap;
extern BlockHeap *lclient_heap; extern rb_bh *lclient_heap;
extern BlockHeap *pclient_heap; extern rb_bh *pclient_heap;
extern char current_uid[IDLEN]; extern char current_uid[IDLEN];
@ -117,9 +117,9 @@ init_client(void)
* start off the check ping event .. -- adrian * start off the check ping event .. -- adrian
* Every 30 seconds is plenty -- db * Every 30 seconds is plenty -- db
*/ */
client_heap = BlockHeapCreate(sizeof(struct Client), CLIENT_HEAP_SIZE); client_heap = rb_bh_create(sizeof(struct Client), CLIENT_HEAP_SIZE);
lclient_heap = BlockHeapCreate(sizeof(struct LocalUser), LCLIENT_HEAP_SIZE); lclient_heap = rb_bh_create(sizeof(struct LocalUser), LCLIENT_HEAP_SIZE);
pclient_heap = BlockHeapCreate(sizeof(struct PreClient), PCLIENT_HEAP_SIZE); pclient_heap = rb_bh_create(sizeof(struct PreClient), PCLIENT_HEAP_SIZE);
rb_event_addish("check_pings", check_pings, NULL, 30); rb_event_addish("check_pings", check_pings, NULL, 30);
rb_event_addish("free_exited_clients", &free_exited_clients, NULL, 4); rb_event_addish("free_exited_clients", &free_exited_clients, NULL, 4);
rb_event_addish("exit_aborted_clients", exit_aborted_clients, NULL, 1); rb_event_addish("exit_aborted_clients", exit_aborted_clients, NULL, 1);
@ -144,13 +144,13 @@ make_client(struct Client *from)
struct Client *client_p = NULL; struct Client *client_p = NULL;
struct LocalUser *localClient; struct LocalUser *localClient;
client_p = BlockHeapAlloc(client_heap); client_p = rb_bh_alloc(client_heap);
if(from == NULL) if(from == NULL)
{ {
client_p->from = client_p; /* 'from' of local client is self! */ client_p->from = client_p; /* 'from' of local client is self! */
localClient = (struct LocalUser *) BlockHeapAlloc(lclient_heap); localClient = (struct LocalUser *) rb_bh_alloc(lclient_heap);
SetMyConnect(client_p); SetMyConnect(client_p);
client_p->localClient = localClient; client_p->localClient = localClient;
@ -159,7 +159,7 @@ make_client(struct Client *from)
client_p->localClient->F = NULL; client_p->localClient->F = NULL;
client_p->localClient->ctrlfd = -1; client_p->localClient->ctrlfd = -1;
client_p->preClient = (struct PreClient *) BlockHeapAlloc(pclient_heap); client_p->preClient = (struct PreClient *) rb_bh_alloc(pclient_heap);
/* as good a place as any... */ /* as good a place as any... */
rb_dlinkAdd(client_p, &client_p->localClient->tnode, &unknown_list); rb_dlinkAdd(client_p, &client_p->localClient->tnode, &unknown_list);
@ -191,7 +191,7 @@ free_pre_client(struct Client *client_p)
if (blptr != NULL) if (blptr != NULL)
unref_blacklist(blptr); unref_blacklist(blptr);
abort_blacklist_queries(client_p); abort_blacklist_queries(client_p);
BlockHeapFree(pclient_heap, client_p->preClient); rb_bh_free(pclient_heap, client_p->preClient);
client_p->preClient = NULL; client_p->preClient = NULL;
} }
@ -231,7 +231,7 @@ free_local_client(struct Client *client_p)
rb_free(client_p->localClient->opername); rb_free(client_p->localClient->opername);
rb_free(client_p->localClient->mangledhost); rb_free(client_p->localClient->mangledhost);
BlockHeapFree(lclient_heap, client_p->localClient); rb_bh_free(lclient_heap, client_p->localClient);
client_p->localClient = NULL; client_p->localClient = NULL;
} }
@ -242,7 +242,7 @@ free_client(struct Client *client_p)
s_assert(&me != client_p); s_assert(&me != client_p);
free_local_client(client_p); free_local_client(client_p);
free_pre_client(client_p); free_pre_client(client_p);
BlockHeapFree(client_heap, client_p); rb_bh_free(client_heap, client_p);
} }
/* /*
@ -1709,7 +1709,7 @@ void
count_local_client_memory(size_t * count, size_t * local_client_memory_used) count_local_client_memory(size_t * count, size_t * local_client_memory_used)
{ {
size_t lusage; size_t lusage;
BlockHeapUsage(lclient_heap, count, NULL, &lusage); rb_bh_usage(lclient_heap, count, NULL, &lusage);
*local_client_memory_used = lusage + (*count * (sizeof(MemBlock) + sizeof(struct Client))); *local_client_memory_used = lusage + (*count * (sizeof(MemBlock) + sizeof(struct Client)));
} }
@ -1720,8 +1720,8 @@ void
count_remote_client_memory(size_t * count, size_t * remote_client_memory_used) count_remote_client_memory(size_t * count, size_t * remote_client_memory_used)
{ {
size_t lcount, rcount; size_t lcount, rcount;
BlockHeapUsage(lclient_heap, &lcount, NULL, NULL); rb_bh_usage(lclient_heap, &lcount, NULL, NULL);
BlockHeapUsage(client_heap, &rcount, NULL, NULL); rb_bh_usage(client_heap, &rcount, NULL, NULL);
*count = rcount - lcount; *count = rcount - lcount;
*remote_client_memory_used = *count * (sizeof(MemBlock) + sizeof(struct Client)); *remote_client_memory_used = *count * (sizeof(MemBlock) + sizeof(struct Client));
} }
@ -1841,11 +1841,11 @@ show_ip_conf(struct ConfItem *aconf, struct Client *source_p)
* side effects - Creates a block heap for struct Users * side effects - Creates a block heap for struct Users
* *
*/ */
static BlockHeap *user_heap; static rb_bh *user_heap;
void void
initUser(void) initUser(void)
{ {
user_heap = BlockHeapCreate(sizeof(struct User), USER_HEAP_SIZE); user_heap = rb_bh_create(sizeof(struct User), USER_HEAP_SIZE);
if(!user_heap) if(!user_heap)
outofmemory(); outofmemory();
} }
@ -1866,7 +1866,7 @@ make_user(struct Client *client_p)
user = client_p->user; user = client_p->user;
if(!user) if(!user)
{ {
user = (struct User *) BlockHeapAlloc(user_heap); user = (struct User *) rb_bh_alloc(user_heap);
user->refcnt = 1; user->refcnt = 1;
client_p->user = user; client_p->user = user;
} }
@ -1932,7 +1932,7 @@ free_user(struct User *user, struct Client *client_p)
s_assert(!user->channel.head); s_assert(!user->channel.head);
} }
BlockHeapFree(user_heap, user); rb_bh_free(user_heap, user);
} }
} }

View File

@ -29,7 +29,7 @@
#include "setup.h" #include "setup.h"
#include "irc_dictionary.h" #include "irc_dictionary.h"
static BlockHeap *elem_heap = NULL; static rb_bh *elem_heap = NULL;
struct Dictionary struct Dictionary
{ {
@ -62,7 +62,7 @@ struct Dictionary *irc_dictionary_create(DCF compare_cb)
dtree->compare_cb = compare_cb; dtree->compare_cb = compare_cb;
if (!elem_heap) if (!elem_heap)
elem_heap = BlockHeapCreate(sizeof(struct DictionaryElement), 1024); elem_heap = rb_bh_create(sizeof(struct DictionaryElement), 1024);
return dtree; return dtree;
} }
@ -93,7 +93,7 @@ struct Dictionary *irc_dictionary_create_named(const char *name,
dtree->id = rb_strdup(name); dtree->id = rb_strdup(name);
if (!elem_heap) if (!elem_heap)
elem_heap = BlockHeapCreate(sizeof(struct DictionaryElement), 1024); elem_heap = rb_bh_create(sizeof(struct DictionaryElement), 1024);
return dtree; return dtree;
} }
@ -364,7 +364,7 @@ irc_dictionary_link(struct Dictionary *dict,
dict->root->data = delem->data; dict->root->data = delem->data;
dict->count--; dict->count--;
BlockHeapFree(elem_heap, delem); rb_bh_free(elem_heap, delem);
} }
} }
} }
@ -473,7 +473,7 @@ void irc_dictionary_destroy(struct Dictionary *dtree,
if (destroy_cb != NULL) if (destroy_cb != NULL)
(*destroy_cb)(n, privdata); (*destroy_cb)(n, privdata);
BlockHeapFree(elem_heap, n); rb_bh_free(elem_heap, n);
} }
rb_free(dtree); rb_free(dtree);
@ -713,14 +713,14 @@ struct DictionaryElement *irc_dictionary_add(struct Dictionary *dict, char *key,
s_assert(data != NULL); s_assert(data != NULL);
s_assert(irc_dictionary_find(dict, key) == NULL); s_assert(irc_dictionary_find(dict, key) == NULL);
delem = BlockHeapAlloc(elem_heap); delem = rb_bh_alloc(elem_heap);
delem->key = key; delem->key = key;
delem->data = data; delem->data = data;
/* TBD: is this needed? --nenolod */ /* TBD: is this needed? --nenolod */
if (delem->key == NULL) if (delem->key == NULL)
{ {
BlockHeapFree(elem_heap, delem); rb_bh_free(elem_heap, delem);
return NULL; return NULL;
} }
@ -759,7 +759,7 @@ void *irc_dictionary_delete(struct Dictionary *dtree, const char *key)
data = delem->data; data = delem->data;
irc_dictionary_unlink_root(dtree); irc_dictionary_unlink_root(dtree);
BlockHeapFree(elem_heap, delem); rb_bh_free(elem_heap, delem);
return data; return data;
} }

View File

@ -128,25 +128,25 @@ int opers_see_all_users = 0;
int testing_conf = 0; int testing_conf = 0;
struct config_channel_entry ConfigChannel; struct config_channel_entry ConfigChannel;
BlockHeap *channel_heap; rb_bh *channel_heap;
BlockHeap *ban_heap; rb_bh *ban_heap;
BlockHeap *topic_heap; rb_bh *topic_heap;
BlockHeap *member_heap; rb_bh *member_heap;
BlockHeap *client_heap = NULL; rb_bh *client_heap = NULL;
BlockHeap *lclient_heap = NULL; rb_bh *lclient_heap = NULL;
BlockHeap *pclient_heap = NULL; rb_bh *pclient_heap = NULL;
char current_uid[IDLEN]; char current_uid[IDLEN];
/* patricia */ /* patricia */
BlockHeap *prefix_heap; rb_bh *prefix_heap;
BlockHeap *node_heap; rb_bh *node_heap;
BlockHeap *patricia_heap; rb_bh *patricia_heap;
BlockHeap *linebuf_heap; rb_bh *linebuf_heap;
BlockHeap *dnode_heap; rb_bh *dnode_heap;
#ifdef NOTYET #ifdef NOTYET

View File

@ -86,7 +86,7 @@ ReportType;
#define sendheader(c, r) sendto_one_notice(c, HeaderMessages[(r)]) #define sendheader(c, r) sendto_one_notice(c, HeaderMessages[(r)])
static rb_dlink_list auth_poll_list; static rb_dlink_list auth_poll_list;
static BlockHeap *auth_heap; static rb_bh *auth_heap;
static EVH timeout_auth_queries_event; static EVH timeout_auth_queries_event;
static PF read_auth_reply; static PF read_auth_reply;
@ -103,7 +103,7 @@ init_auth(void)
/* This hook takes a struct Client for its argument */ /* This hook takes a struct Client for its argument */
memset(&auth_poll_list, 0, sizeof(auth_poll_list)); memset(&auth_poll_list, 0, sizeof(auth_poll_list));
eventAddIsh("timeout_auth_queries_event", timeout_auth_queries_event, NULL, 1); eventAddIsh("timeout_auth_queries_event", timeout_auth_queries_event, NULL, 1);
auth_heap = BlockHeapCreate(sizeof(struct AuthRequest), LCLIENT_HEAP_SIZE); auth_heap = rb_bh_create(sizeof(struct AuthRequest), LCLIENT_HEAP_SIZE);
} }
/* /*
@ -112,7 +112,7 @@ init_auth(void)
static struct AuthRequest * static struct AuthRequest *
make_auth_request(struct Client *client) make_auth_request(struct Client *client)
{ {
struct AuthRequest *request = BlockHeapAlloc(auth_heap); struct AuthRequest *request = rb_bh_alloc(auth_heap);
client->localClient->auth_request = request; client->localClient->auth_request = request;
request->fd = -1; request->fd = -1;
request->client = client; request->client = client;
@ -126,7 +126,7 @@ make_auth_request(struct Client *client)
static void static void
free_auth_request(struct AuthRequest *request) free_auth_request(struct AuthRequest *request)
{ {
BlockHeapFree(auth_heap, request); rb_bh_free(auth_heap, request);
} }
/* /*

View File

@ -59,7 +59,7 @@ extern char linebuf[];
#define INADDR_NONE ((unsigned int) 0xffffffff) #define INADDR_NONE ((unsigned int) 0xffffffff)
#endif #endif
static BlockHeap *confitem_heap = NULL; static rb_bh *confitem_heap = NULL;
rb_dlink_list temp_klines[LAST_TEMP_TYPE]; rb_dlink_list temp_klines[LAST_TEMP_TYPE];
rb_dlink_list temp_dlines[LAST_TEMP_TYPE]; rb_dlink_list temp_dlines[LAST_TEMP_TYPE];
@ -83,7 +83,7 @@ static int attach_iline(struct Client *, struct ConfItem *);
void void
init_s_conf(void) init_s_conf(void)
{ {
confitem_heap = BlockHeapCreate(sizeof(struct ConfItem), CONFITEM_HEAP_SIZE); confitem_heap = rb_bh_create(sizeof(struct ConfItem), CONFITEM_HEAP_SIZE);
eventAddIsh("expire_temp_klines", expire_temp_kd, &temp_klines[TEMP_MIN], 60); eventAddIsh("expire_temp_klines", expire_temp_kd, &temp_klines[TEMP_MIN], 60);
eventAddIsh("expire_temp_dlines", expire_temp_kd, &temp_dlines[TEMP_MIN], 60); eventAddIsh("expire_temp_dlines", expire_temp_kd, &temp_dlines[TEMP_MIN], 60);
@ -114,7 +114,7 @@ make_conf()
{ {
struct ConfItem *aconf; struct ConfItem *aconf;
aconf = BlockHeapAlloc(confitem_heap); aconf = rb_bh_alloc(confitem_heap);
aconf->status = CONF_ILLEGAL; aconf->status = CONF_ILLEGAL;
return (aconf); return (aconf);
} }
@ -146,7 +146,7 @@ free_conf(struct ConfItem *aconf)
rb_free(aconf->user); rb_free(aconf->user);
rb_free(aconf->host); rb_free(aconf->host);
BlockHeapFree(confitem_heap, aconf); rb_bh_free(confitem_heap, aconf);
} }
/* /*

View File

@ -58,7 +58,7 @@ rb_dlink_list tgchange_list;
rb_patricia_tree_t *tgchange_tree; rb_patricia_tree_t *tgchange_tree;
static BlockHeap *nd_heap = NULL; static rb_bh *nd_heap = NULL;
static void expire_temp_rxlines(void *unused); static void expire_temp_rxlines(void *unused);
static void expire_nd_entries(void *unused); static void expire_nd_entries(void *unused);
@ -67,7 +67,7 @@ void
init_s_newconf(void) init_s_newconf(void)
{ {
tgchange_tree = New_Patricia(PATRICIA_BITS); tgchange_tree = New_Patricia(PATRICIA_BITS);
nd_heap = BlockHeapCreate(sizeof(struct nd_entry), ND_HEAP_SIZE); nd_heap = rb_bh_create(sizeof(struct nd_entry), ND_HEAP_SIZE);
eventAddIsh("expire_nd_entries", expire_nd_entries, NULL, 30); eventAddIsh("expire_nd_entries", expire_nd_entries, NULL, 30);
eventAddIsh("expire_temp_rxlines", expire_temp_rxlines, NULL, 60); eventAddIsh("expire_temp_rxlines", expire_temp_rxlines, NULL, 60);
} }
@ -751,7 +751,7 @@ add_nd_entry(const char *name)
if(irc_dictionary_find(nd_dict, name) != NULL) if(irc_dictionary_find(nd_dict, name) != NULL)
return; return;
nd = BlockHeapAlloc(nd_heap); nd = rb_bh_alloc(nd_heap);
strlcpy(nd->name, name, sizeof(nd->name)); strlcpy(nd->name, name, sizeof(nd->name));
nd->expire = rb_current_time() + ConfigFileEntry.nick_delay; nd->expire = rb_current_time() + ConfigFileEntry.nick_delay;
@ -768,7 +768,7 @@ free_nd_entry(struct nd_entry *nd)
irc_dictionary_delete(nd_dict, nd->name); irc_dictionary_delete(nd_dict, nd->name);
rb_dlinkDelete(&nd->lnode, &nd_list); rb_dlinkDelete(&nd->lnode, &nd_list);
BlockHeapFree(nd_heap, nd); rb_bh_free(nd_heap, nd);
} }
void void