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

Comparing ircd-hybrid/trunk/src/client.c (file contents):
Revision 1644 by michael, Tue Nov 6 22:20:16 2012 UTC vs.
Revision 1798 by michael, Sun Mar 31 17:09:50 2013 UTC

# Line 45 | Line 45
45   #include "s_user.h"
46   #include "dbuf.h"
47   #include "memory.h"
48 + #include "mempool.h"
49   #include "hostmask.h"
49 #include "balloc.h"
50   #include "listener.h"
51   #include "irc_res.h"
52   #include "userhost.h"
53   #include "watch.h"
54 + #include "rng_mt.h"
55  
56   dlink_list listing_client_list = { NULL, NULL, 0 };
57   /* Pointer to beginning of Client list */
# Line 64 | Line 65 | dlink_list oper_list = {NULL, NULL, 0};
65  
66   static EVH check_pings;
67  
68 < static BlockHeap *client_heap  = NULL;
69 < static BlockHeap *lclient_heap = NULL;
68 > static mp_pool_t *client_pool  = NULL;
69 > static mp_pool_t *lclient_pool = NULL;
70  
71   static dlink_list dead_list  = { NULL, NULL, 0};
72   static dlink_list abort_list = { NULL, NULL, 0};
# Line 77 | Line 78 | static void check_unknowns_list(void);
78   static void ban_them(struct Client *, struct MaskItem *);
79  
80  
81 < /* init_client()
81 > /* client_init()
82   *
83   * inputs       - NONE
84   * output       - NONE
85   * side effects - initialize client free memory
86   */
87   void
88 < init_client(void)
88 > client_init(void)
89   {
90    /* start off the check ping event ..  -- adrian
91     * Every 30 seconds is plenty -- db
92     */
93 <  client_heap = BlockHeapCreate("client", sizeof(struct Client), CLIENT_HEAP_SIZE);
94 <  lclient_heap = BlockHeapCreate("local client", sizeof(struct LocalUser), LCLIENT_HEAP_SIZE);
93 >  client_pool = mp_pool_new(sizeof(struct Client), MP_CHUNK_SIZE_CLIENT);
94 >  lclient_pool = mp_pool_new(sizeof(struct LocalUser), MP_CHUNK_SIZE_LCLIENT);
95    eventAdd("check_pings", check_pings, NULL, 5);
96   }
97  
# Line 112 | Line 113 | init_client(void)
113   struct Client *
114   make_client(struct Client *from)
115   {
116 <  struct Client *client_p = BlockHeapAlloc(client_heap);
116 >  struct Client *client_p = mp_pool_get(client_pool);
117 >
118 >  memset(client_p, 0, sizeof(*client_p));
119  
120    if (from == NULL)
121    {
122      client_p->from                      = client_p; /* 'from' of local client is self! */
123 <    client_p->localClient               = BlockHeapAlloc(lclient_heap);
123 >    client_p->localClient               = mp_pool_get(lclient_pool);
124 >
125 >    memset(client_p->localClient, 0, sizeof(*client_p->localClient));
126 >
127      client_p->localClient->since        = CurrentTime;
128      client_p->localClient->lasttime     = CurrentTime;
129      client_p->localClient->firsttime    = CurrentTime;
# Line 155 | Line 161 | free_client(struct Client *client_p)
161    assert(client_p->channel.head == NULL);
162    assert(dlink_list_length(&client_p->channel) == 0);
163    assert(dlink_list_length(&client_p->whowas) == 0);
164 <  assert(!IsServer(client_p) || IsServer(client_p) && client_p->serv);
164 >  assert(!IsServer(client_p) || (IsServer(client_p) && client_p->serv));
165  
166    MyFree(client_p->serv);
167  
# Line 183 | Line 189 | free_client(struct Client *client_p)
189      dbuf_clear(&client_p->localClient->buf_recvq);
190      dbuf_clear(&client_p->localClient->buf_sendq);
191  
192 <    BlockHeapFree(lclient_heap, client_p->localClient);
192 >    mp_pool_release(client_p->localClient);
193    }
194  
195 <  BlockHeapFree(client_heap, client_p);
195 >  mp_pool_release(client_p);
196   }
197  
198   /*
# Line 653 | Line 659 | exit_one_client(struct Client *source_p,
659       * that the client can show the "**signoff" message).
660       * (Note: The notice is to the local clients *only*)
661       */
662 <    sendto_common_channels_local(source_p, 0, ":%s!%s@%s QUIT :%s",
662 >    sendto_common_channels_local(source_p, 0, 0, ":%s!%s@%s QUIT :%s",
663                                   source_p->name, source_p->username,
664                                   source_p->host, quitmsg);
665      DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head)
# Line 1121 | Line 1127 | find_accept(const char *nick, const char
1127    {
1128      struct split_nuh_item *accept_p = ptr->data;
1129  
1130 <    if (cmpfunc(accept_p->nickptr, nick) == do_match &&
1131 <        cmpfunc(accept_p->userptr, user) == do_match &&
1132 <        cmpfunc(accept_p->hostptr, host) == do_match)
1130 >    if (!cmpfunc(accept_p->nickptr, nick) &&
1131 >        !cmpfunc(accept_p->userptr, user) &&
1132 >        !cmpfunc(accept_p->hostptr, host))
1133        return accept_p;
1134    }
1135  
# Line 1169 | Line 1175 | del_all_accepts(struct Client *client_p)
1175    DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head)
1176      del_accept(ptr->data, client_p);
1177   }
1178 +
1179 + unsigned int
1180 + idle_time_get(const struct Client *source_p, const struct Client *target_p)
1181 + {
1182 +  unsigned int idle = 0;
1183 +  unsigned int min_idle = 0;
1184 +  unsigned int max_idle = 0;
1185 +  struct ClassItem *class = get_class_ptr(&target_p->localClient->confs);
1186 +
1187 +  if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p)
1188 +    return CurrentTime - target_p->localClient->last_privmsg;
1189 +  if (HasUMode(source_p, UMODE_OPER) &&
1190 +      !(class->flags & CLASS_FLAGS_HIDE_IDLE_FROM_OPERS))
1191 +    return CurrentTime - target_p->localClient->last_privmsg;
1192 +
1193 +  min_idle = class->min_idle;
1194 +  max_idle = class->max_idle;
1195 +
1196 +  if (min_idle == max_idle)
1197 +    return min_idle;
1198 +
1199 +  if (class->flags & CLASS_FLAGS_RANDOM_IDLE)
1200 +    idle = genrand_int32();
1201 +  else
1202 +    idle = CurrentTime - target_p->localClient->last_privmsg;
1203 +
1204 +  if (max_idle == 0)
1205 +    idle = 0;
1206 +  else
1207 +    idle %= max_idle;
1208 +
1209 +  if (idle < min_idle)
1210 +    idle = min_idle + (idle % (max_idle - min_idle));
1211 +
1212 +  return idle;
1213 + }

Diff Legend

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