ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/watch.c
(Generate patch)

Comparing:
ircd-hybrid/src/watch.c (file contents), Revision 1155 by michael, Tue Aug 9 20:27:45 2011 UTC vs.
ircd-hybrid/trunk/src/watch.c (file contents), Revision 1834 by michael, Fri Apr 19 19:50:27 2013 UTC

# Line 27 | Line 27
27  
28   #include "stdinc.h"
29   #include "list.h"
30 – #include "balloc.h"
31 – #include "s_user.h"
32 – #include "s_misc.h"
30   #include "client.h"
31   #include "hash.h"
32   #include "irc_string.h"
36 – #include "sprintf_irc.h"
33   #include "ircd.h"
34   #include "numeric.h"
35 < #include "s_conf.h"
40 < #include "s_serv.h"
35 > #include "conf.h"
36   #include "send.h"
37 < #include "supported.h"
43 < #include "whowas.h"
44 < #include "memory.h"
45 < #include "packet.h"
46 < #include "s_misc.h"
37 > #include "mempool.h"
38   #include "watch.h"
39  
49 – #define WATCH_HEAP_SIZE 32
40  
41   static dlink_list watchTable[HASHSIZE];
42  
43 < static BlockHeap *watch_heap = NULL;
43 > static mp_pool_t *watch_pool = NULL;
44  
45   /*! \brief Initializes the watch table
46   */
47   void
48   watch_init(void)
49   {
50 <  memset(watchTable, 0, sizeof(watchTable));
61 <
62 <  watch_heap = BlockHeapCreate("watch", sizeof(struct Watch), WATCH_HEAP_SIZE);
50 >  watch_pool = mp_pool_new(sizeof(struct Watch), MP_CHUNK_SIZE_WATCH);
51   }
52  
53   /*
# Line 100 | Line 88 | watch_check_hash(struct Client *client_p
88    dlink_node *ptr = NULL;
89    assert(IsClient(client_p));
90    if ((anptr = watch_find_hash(client_p->name)) == NULL)
91 <    return;    // This nick isn't on watch
91 >    return;    /* This nick isn't on watch */
92  
93 <  // Update the time of last change to item
93 >  /* Update the time of last change to item */
94    anptr->lasttime = CurrentTime;
95  
96 <  // Send notifies out to everybody on the list in header
96 >  /* Send notifies out to everybody on the list in header */
97    DLINK_FOREACH(ptr, anptr->watched_by.head)
98    {
99      struct Client *target_p = ptr->data;
# Line 146 | Line 134 | watch_add_to_hash_table(const char *nick
134    struct Watch *anptr = NULL;
135    dlink_node *ptr = NULL;
136  
137 <  // If found NULL (no header for this nick), make one...
137 >  /* If found NULL (no header for this nick), make one... */
138    if ((anptr = watch_find_hash(nick)) == NULL)
139    {
140 <    anptr = BlockHeapAlloc(watch_heap);
140 >    anptr = mp_pool_get(watch_pool);
141 >    memset(anptr, 0, sizeof(*anptr));
142      anptr->lasttime = CurrentTime;
143      strlcpy(anptr->nick, nick, sizeof(anptr->nick));
144  
# Line 157 | Line 146 | watch_add_to_hash_table(const char *nick
146    }
147    else
148    {
149 <    // Is this client already on the watch-list?
149 >    /* Is this client already on the watch-list? */
150      ptr = dlinkFind(&anptr->watched_by, client_p);
151    }
152  
153    if (ptr == NULL)
154    {
155 <    // No it isn't, so add it in the bucket and client addint it
155 >    /* No it isn't, so add it in the bucket and client addint it */
156      dlinkAdd(client_p, make_dlink_node(), &anptr->watched_by);
157      dlinkAdd(anptr, make_dlink_node(), &client_p->localClient->watches);
158    }
# Line 180 | Line 169 | watch_del_from_hash_table(const char *ni
169    dlink_node *ptr = NULL;
170  
171    if ((anptr = watch_find_hash(nick)) == NULL)
172 <    return;    // No header found for that nick. i.e. it's not being watched
172 >    return;    /* No header found for that nick. i.e. it's not being watched */
173  
174    if ((ptr = dlinkFind(&anptr->watched_by, client_p)) == NULL)
175 <    return;    // This nick isn't being watched by client_p
175 >    return;    /* This nick isn't being watched by client_p */
176  
177    dlinkDelete(ptr, &anptr->watched_by);
178    free_dlink_node(ptr);
# Line 191 | Line 180 | watch_del_from_hash_table(const char *ni
180    if ((ptr = dlinkFindDelete(&client_p->localClient->watches, anptr)))
181      free_dlink_node(ptr);
182  
183 <  // In case this header is now empty of notices, remove it
183 >  /* In case this header is now empty of notices, remove it */
184    if (anptr->watched_by.head == NULL)
185    {
186      assert(dlinkFind(&watchTable[strhash(nick)], anptr) != NULL);
187      dlinkDelete(&anptr->node, &watchTable[strhash(nick)]);
188 <    BlockHeapFree(watch_heap, anptr);
188 >    mp_pool_release(anptr);
189    }
190   }
191  
# Line 220 | Line 209 | watch_del_watch_list(struct Client *clie
209      if ((tmp = dlinkFindDelete(&anptr->watched_by, client_p)))
210        free_dlink_node(tmp);
211  
212 <    // If this leaves a header without notifies, remove it.
212 >    /* If this leaves a header without notifies, remove it. */
213      if (anptr->watched_by.head == NULL)
214      {
215        assert(dlinkFind(&watchTable[strhash(anptr->nick)], anptr) != NULL);
216        dlinkDelete(&anptr->node, &watchTable[strhash(anptr->nick)]);
217  
218 <      BlockHeapFree(watch_heap, anptr);
218 >      mp_pool_release(anptr);
219      }
220  
221      dlinkDelete(ptr, &client_p->localClient->watches);

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)