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

Comparing:
ircd-hybrid/src/s_bsd_kqueue.c (file contents), Revision 1028 by michael, Sun Nov 8 13:03:38 2009 UTC vs.
ircd-hybrid/trunk/src/s_bsd_kqueue.c (file contents), Revision 2916 by michael, Sat Jan 25 21:09:18 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_bsd_kqueue.c: FreeBSD kqueue compatible network routines.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Originally by Adrian Chadd <adrian@creative.net.au>
6 < *  Copyright (C) 2005 Hybrid Development Team
4 > *  Copyright (c) 2000-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 19 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file s_bsd_kqueue.c
23 > * \brief kqueue() compatible network routines.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
# Line 30 | Line 31
31   #include "ircd.h"
32   #include "memory.h"
33   #include "s_bsd.h"
34 < #include "s_log.h"
34 > #include "log.h"
35  
36   #define KE_LENGTH 128
37  
# Line 50 | Line 51
51   static fde_t kqfd;
52   static struct kevent kq_fdlist[KE_LENGTH];  /* kevent buffer */
53   static int kqoff;      /* offset into the buffer */
53 void init_netio(void);
54  
55   /*
56   * init_netio
# Line 65 | Line 65 | init_netio(void)
65  
66    if ((fd = kqueue()) < 0)
67    {
68 <    ilog(L_CRIT, "init_netio: Couldn't open kqueue fd!");
68 >    ilog(LOG_TYPE_IRCD, "init_netio: Couldn't open kqueue fd!");
69      exit(115); /* Whee! */
70    }
71  
# Line 85 | Line 85 | kq_update_events(int fd, int filter, int
85  
86    if (++kqoff == KE_LENGTH)
87    {
88 <    kevent(kqfd.fd, kq_fdlist, kqoff, NULL, 0, &zero_timespec);
88 >    int i;
89 >
90 >    for (i = 0; i < kqoff; ++i)
91 >      kevent(kqfd.fd, &kq_fdlist[i], 1, NULL, 0, &zero_timespec);
92      kqoff = 0;
93    }
94   }
# Line 115 | Line 118 | comm_setselect(fde_t *F, unsigned int ty
118    }
119  
120    new_events = (F->read_handler ? COMM_SELECT_READ : 0) |
121 <   (F->write_handler ? COMM_SELECT_WRITE : 0);
121 >               (F->write_handler ? COMM_SELECT_WRITE : 0);
122  
123    if (timeout != 0)
124 +  {
125      F->timeout = CurrentTime + (timeout / 1000);
126 +    F->timeout_handler = handler;
127 +    F->timeout_data = client_data;
128 +  }
129  
130    diff = new_events ^ F->evcache;
131  
# Line 176 | Line 183 | comm_select(void)
183        continue;
184  
185      if (ke[i].filter == EVFILT_READ)
186 +    {
187        if ((hdl = F->read_handler) != NULL)
188        {
189          F->read_handler = NULL;
190          hdl(F, F->read_data);
191 <        if (!F->flags.open)
192 <          continue;
191 >        if (!F->flags.open)
192 >          continue;
193        }
194 +    }
195  
196      if (ke[i].filter == EVFILT_WRITE)
197 +    {
198        if ((hdl = F->write_handler) != NULL)
199        {
200          F->write_handler = NULL;
201          hdl(F, F->write_data);
202 <        if (!F->flags.open)
203 <          continue;
202 >        if (!F->flags.open)
203 >          continue;
204        }
205 +    }
206  
207      comm_setselect(F, 0, NULL, NULL, 0);
208    }

Diff Legend

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