… | |
… | |
21 | void epoll_postfork_child (void) |
21 | void epoll_postfork_child (void) |
22 | { |
22 | { |
23 | int fd; |
23 | int fd; |
24 | |
24 | |
25 | epoll_fd = epoll_create (256); |
25 | epoll_fd = epoll_create (256); |
|
|
26 | fcntl (epoll_fd, F_SETFD, FD_CLOEXEC); |
26 | |
27 | |
27 | /* re-register interest in fds */ |
28 | /* re-register interest in fds */ |
28 | for (fd = 0; fd < anfdmax; ++fd) |
29 | for (fd = 0; fd < anfdmax; ++fd) |
29 | if (anfds [fd].wev) |
30 | if (anfds [fd].wev) |
30 | epoll_modify (fd, EV_NONE, anfds [fd].wev); |
31 | epoll_modify (fd, EV_NONE, anfds [fd].wev); |
… | |
… | |
55 | eventmax += eventmax >> 1; |
56 | eventmax += eventmax >> 1; |
56 | events = malloc (sizeof (struct epoll_event) * eventmax); |
57 | events = malloc (sizeof (struct epoll_event) * eventmax); |
57 | } |
58 | } |
58 | } |
59 | } |
59 | |
60 | |
60 | int epoll_init (int flags) |
61 | void epoll_init (int flags) |
61 | { |
62 | { |
62 | epoll_fd = epoll_create (256); |
63 | epoll_fd = epoll_create (256); |
63 | |
64 | |
64 | if (epoll_fd < 0) |
65 | if (epoll_fd < 0) |
65 | return 0; |
66 | return; |
66 | |
67 | |
|
|
68 | fcntl (epoll_fd, F_SETFD, FD_CLOEXEC); |
|
|
69 | |
67 | ev_method = EVMETHOD_EPOLL; |
70 | ev_method = EVMETHOD_EPOLL; |
68 | method_fudge = 1e-3; /* needed to compensate for epoll returning early */ |
71 | method_fudge = 1e-3; /* needed to compensate for epoll returning early */ |
69 | method_modify = epoll_modify; |
72 | method_modify = epoll_modify; |
70 | method_poll = epoll_poll; |
73 | method_poll = epoll_poll; |
71 | |
74 | |
72 | eventmax = 64; /* intiial number of events receivable per poll */ |
75 | eventmax = 64; /* intiial number of events receivable per poll */ |
73 | events = malloc (sizeof (struct epoll_event) * eventmax); |
76 | events = malloc (sizeof (struct epoll_event) * eventmax); |
74 | |
|
|
75 | return 1; |
|
|
76 | } |
77 | } |