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 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/src/s_bsd_kqueue.c (file contents), Revision 3984 by michael, Wed Jun 18 13:24:34 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: s_bsd_kqueue.c,v 1.45 2005/09/29 06:35:41 metalrock Exp $
20 > */
21 >
22 > /*! \file s_bsd_kqueue.c
23 > * \brief kqueue() compatible network routines.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28 + #if USE_IOPOLL_MECHANISM == __IOPOLL_MECHANISM_KQUEUE
29   #include <sys/event.h>
30   #include "fdlist.h"
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  
36 /* jlemon goofed up and didn't add EV_SET until fbsd 4.3 */
37
38 #ifndef EV_SET
39 #define EV_SET(kevp, a, b, c, d, e, f) do {     \
40        (kevp)->ident = (a);                    \
41        (kevp)->filter = (b);                   \
42        (kevp)->flags = (c);                    \
43        (kevp)->fflags = (d);                   \
44        (kevp)->data = (e);                     \
45        (kevp)->udata = (f);                    \
46 } while(0)
47 #endif
48
38   static fde_t kqfd;
39   static struct kevent kq_fdlist[KE_LENGTH];  /* kevent buffer */
40   static int kqoff;      /* offset into the buffer */
41 < void init_netio(void);
41 >
42  
43   /*
44   * init_netio
# Line 64 | Line 53 | init_netio(void)
53  
54    if ((fd = kqueue()) < 0)
55    {
56 <    ilog(L_CRIT, "init_netio: Couldn't open kqueue fd!");
56 >    ilog(LOG_TYPE_IRCD, "init_netio: Couldn't open kqueue fd!");
57      exit(115); /* Whee! */
58    }
59  
# Line 82 | Line 71 | kq_update_events(int fd, int filter, int
71  
72    EV_SET(kep, (uintptr_t) fd, (short) filter, what, 0, 0, NULL);
73  
74 <  if (kqoff == KE_LENGTH)
74 >  if (++kqoff == KE_LENGTH)
75    {
76 <    kevent(kqfd.fd, kq_fdlist, kqoff, NULL, 0, &zero_timespec);
76 >    int i;
77 >
78 >    for (i = 0; i < kqoff; ++i)
79 >      kevent(kqfd.fd, &kq_fdlist[i], 1, NULL, 0, &zero_timespec);
80      kqoff = 0;
81    }
90  else
91    kqoff++;
82   }
83  
84   /*
# Line 116 | Line 106 | comm_setselect(fde_t *F, unsigned int ty
106    }
107  
108    new_events = (F->read_handler ? COMM_SELECT_READ : 0) |
109 <   (F->write_handler ? COMM_SELECT_WRITE : 0);
109 >               (F->write_handler ? COMM_SELECT_WRITE : 0);
110  
111    if (timeout != 0)
112 +  {
113      F->timeout = CurrentTime + (timeout / 1000);
114 +    F->timeout_handler = handler;
115 +    F->timeout_data = client_data;
116 +  }
117  
118    diff = new_events ^ F->evcache;
119  
# Line 177 | Line 171 | comm_select(void)
171        continue;
172  
173      if (ke[i].filter == EVFILT_READ)
174 +    {
175        if ((hdl = F->read_handler) != NULL)
176        {
177          F->read_handler = NULL;
178          hdl(F, F->read_data);
179 <        if (!F->flags.open)
180 <          continue;
179 >        if (!F->flags.open)
180 >          continue;
181        }
182 +    }
183  
184      if (ke[i].filter == EVFILT_WRITE)
185 +    {
186        if ((hdl = F->write_handler) != NULL)
187        {
188          F->write_handler = NULL;
189          hdl(F, F->write_data);
190 <        if (!F->flags.open)
191 <          continue;
190 >        if (!F->flags.open)
191 >          continue;
192        }
193 +    }
194  
195      comm_setselect(F, 0, NULL, NULL, 0);
196    }
197   }
198 + #endif

Comparing:
ircd-hybrid/src/s_bsd_kqueue.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/src/s_bsd_kqueue.c (property svn:keywords), Revision 3984 by michael, Wed Jun 18 13:24:34 2014 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

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