| 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 |
| 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 |
|
/* |
| 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 |
|
} |
| 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 |
|
|
| 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)) |
| 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 |
|
} |
| 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 |
|
} |