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

Comparing ircd-hybrid/branches/8.2.x/src/s_bsd_devpoll.c (file contents):
Revision 8280 by michael, Tue Feb 20 19:30:33 2018 UTC vs.
Revision 8338 by michael, Sat Mar 3 22:26:59 2018 UTC

# Line 42 | Line 42
42   #include "s_bsd.h"
43   #include "log.h"
44  
45 < static fde_t dpfd;
45 > static int devpoll_fd;
46  
47   /*
48   * netio_init
# Line 53 | Line 53 | static fde_t dpfd;
53   void
54   netio_init(void)
55   {
56 <  int fd;
57 <
58 <  if ((fd = open("/dev/poll", O_RDWR)) < 0)
56 >  if ((devpoll_fd = open("/dev/poll", O_RDWR)) < 0)
57    {
58      ilog(LOG_TYPE_IRCD, "netio_init: couldn't open /dev/poll: %s",
59           strerror(errno));
60      exit(EXIT_FAILURE); /* Whee! */
61    }
62  
63 <  fd_open(&dpfd, fd, 0, "/dev/poll file descriptor");
63 >  fd_open(devpoll_fd, 0, "/dev/poll file descriptor");
64   }
65  
66   /*
# Line 82 | Line 80 | devpoll_write_update(int fd, int events)
80    pfd.events = events;
81  
82    /* Write the thing to our poll fd */
83 <  if (write(dpfd.fd, &pfd, sizeof(pfd)) != sizeof(pfd))
83 >  if (write(devpoll_fd, &pfd, sizeof(pfd)) != sizeof(pfd))
84      ilog(LOG_TYPE_IRCD, "devpoll_write_update: dpfd write failed %d: %s",
85           errno, strerror(errno));
86   }
# Line 144 | Line 142 | comm_select(void)
142    struct pollfd pollfds[128];
143    struct dvpoll dopoll;
144    void (*hdl)(fde_t *, void *);
147  fde_t *F;
145  
146    dopoll.dp_timeout = SELECT_DELAY;
147    dopoll.dp_nfds = 128;
148    dopoll.dp_fds = &pollfds[0];
149 <  num = ioctl(dpfd.fd, DP_POLL, &dopoll);
149 >  num = ioctl(devpoll_fd, DP_POLL, &dopoll);
150  
151    set_time();
152  
# Line 162 | Line 159 | comm_select(void)
159  
160    for (i = 0; i < num; i++)
161    {
162 <    F = lookup_fd(dopoll.dp_fds[i].fd);
163 <    if (F == NULL || !F->flags.open)
162 >    fde_t *F = &fd_table[dopoll.dp_fds[i].fd];
163 >
164 >    if (F->flags.open == 0)
165        continue;
166  
167      if ((dopoll.dp_fds[i].revents & POLLIN))
# Line 172 | Line 170 | comm_select(void)
170        {
171          F->read_handler = NULL;
172          hdl(F, F->read_data);
173 <        if (!F->flags.open)
173 >
174 >        if (F->flags.open == 0)
175            continue;
176        }
177      }
# Line 183 | Line 182 | comm_select(void)
182        {
183          F->write_handler = NULL;
184          hdl(F, F->write_data);
185 <        if (!F->flags.open)
185 >
186 >        if (F->flags.open == 0)
187            continue;
188        }
189      }

Diff Legend

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