split up constants.h some
[trinity.git] / fd-epoll.c
blob688006437b66b393951baac77d7109410df194a3
1 /* epoll related fds */
3 #include <errno.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
8 #include <sys/epoll.h>
9 #include <sys/eventfd.h>
11 #include "epoll.h"
12 #include "log.h"
13 #include "net.h"
14 #include "params.h"
15 #include "pids.h"
16 #include "random.h"
17 #include "sanitise.h"
18 #include "shm.h"
19 #include "trinity.h"
21 void open_epoll_fds(void)
23 unsigned int i = 0;
24 int fd = -1;
26 while (i < MAX_EPOLL_FDS) {
28 if (rand_bool())
29 fd = epoll_create(1);
30 else
31 fd = epoll_create1(EPOLL_CLOEXEC);
33 if (fd != -1) {
34 shm->epoll_fds[i] = fd;
35 output(2, "fd[%d] = epoll\n", shm->epoll_fds[i]);
36 i++;
41 int rand_epoll_fd(void)
43 return shm->epoll_fds[rand() % MAX_EPOLL_FDS];