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

Comparing:
ircd-hybrid-7.2/src/s_bsd_devpoll.c (file contents), Revision 242 by adx, Sun Nov 6 11:20:44 2005 UTC vs.
ircd-hybrid/trunk/src/s_bsd_devpoll.c (file contents), Revision 5347 by michael, Sun Jan 11 12:42:20 2015 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_bsd_devpoll.c: /dev/poll 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) 2002 Hybrid Development Team
4 > *  Copyright (c) 2001-2015 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 17 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file s_bsd_devpoll.c
23 > * \brief /dev/poll compatible network routines.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28 + #if USE_IOPOLL_MECHANISM == __IOPOLL_MECHANISM_DEVPOLL
29   #include <sys/ioctl.h>
30   /* HPUX uses devpoll.h and not sys/devpoll.h */
31   #ifdef HAVE_DEVPOLL_H
# Line 38 | Line 40
40   #include "fdlist.h"
41   #include "ircd.h"
42   #include "s_bsd.h"
43 < #include "s_log.h"
43 > #include "log.h"
44  
45   static fde_t dpfd;
46  
# Line 55 | Line 57 | init_netio(void)
57  
58    if ((fd = open("/dev/poll", O_RDWR)) < 0)
59    {
60 <    ilog(L_CRIT, "init_netio: Couldn't open /dev/poll - %d: %s",
60 >    ilog(LOG_TYPE_IRCD, "init_netio: Couldn't open /dev/poll - %d: %s",
61           errno, strerror(errno));
62      exit(115); /* Whee! */
63    }
# Line 81 | Line 83 | devpoll_write_update(int fd, int events)
83  
84    /* Write the thing to our poll fd */
85    if (write(dpfd.fd, &pfd, sizeof(pfd)) != sizeof(pfd))
86 <    ilog(L_NOTICE, "devpoll_write_update: dpfd write failed %d: %s",
86 >    ilog(LOG_TYPE_IRCD, "devpoll_write_update: dpfd write failed %d: %s",
87           errno, strerror(errno));
88   }
89  
# Line 92 | Line 94 | devpoll_write_update(int fd, int events)
94   * and deregister interest in a pending IO state for a given FD.
95   */
96   void
97 < comm_setselect(fde_t *F, unsigned int type, PF *handler,
97 > comm_setselect(fde_t *F, unsigned int type, void (*handler)(fde_t *, void *),
98                 void *client_data, time_t timeout)
99   {
100    int new_events;
# Line 109 | Line 111 | comm_setselect(fde_t *F, unsigned int ty
111      F->write_data = client_data;
112    }
113  
114 <  new_events = (F->read_handler ? POLLRDNORM : 0) |
115 <    (F->write_handler ? POLLWRNORM : 0);
114 >  new_events = (F->read_handler ? POLLIN : 0) |
115 >    (F->write_handler ? POLLOUT : 0);
116  
117    if (timeout != 0)
118 +  {
119      F->timeout = CurrentTime + (timeout / 1000);
120 +    F->timeout_handler = handler;
121 +    F->timeout_data = client_data;
122 +  }
123  
124    if (new_events != F->evcache)
125    {
# Line 137 | Line 143 | comm_select(void)
143    int num, i;
144    struct pollfd pollfds[128];
145    struct dvpoll dopoll;
146 <  PF *hdl;
146 >  void (*hdl)(fde_t *, void *);
147    fde_t *F;
148  
149    dopoll.dp_timeout = SELECT_DELAY;
# Line 161 | Line 167 | comm_select(void)
167      if (F == NULL || !F->flags.open)
168        continue;
169  
170 <    if ((dopoll.dp_fds[i].revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR)))
170 >    if ((dopoll.dp_fds[i].revents & POLLIN))
171 >    {
172        if ((hdl = F->read_handler) != NULL)
173        {
174          F->read_handler = NULL;
# Line 169 | Line 176 | comm_select(void)
176          if (!F->flags.open)
177            continue;
178        }
179 +    }
180  
181 <    if ((dopoll.dp_fds[i].revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR)))
182 <      if ((hdl = F->write_handler) != NULL)
181 >    if ((dopoll.dp_fds[i].revents & POLLOUT))
182 >    {
183 >      if ((hdl = F->write_handler) != NULL)
184        {
185          F->write_handler = NULL;
186          hdl(F, F->write_data);
187          if (!F->flags.open)
188            continue;
189        }
190 +    }
191  
192      comm_setselect(F, 0, NULL, NULL, 0);
193    }
194   }
195 + #endif

Diff Legend

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