… | |
… | |
43 | | (nev & EV_WRITE ? EPOLLOUT : 0); |
43 | | (nev & EV_WRITE ? EPOLLOUT : 0); |
44 | |
44 | |
45 | epoll_ctl (epoll_fd, mode, fd, &ev); |
45 | epoll_ctl (epoll_fd, mode, fd, &ev); |
46 | } |
46 | } |
47 | |
47 | |
|
|
48 | static void |
48 | void epoll_postfork_child (void) |
49 | epoll_postfork_child (void) |
49 | { |
50 | { |
50 | int fd; |
51 | int fd; |
51 | |
52 | |
52 | epoll_fd = epoll_create (256); |
53 | epoll_fd = epoll_create (256); |
53 | fcntl (epoll_fd, F_SETFD, FD_CLOEXEC); |
54 | fcntl (epoll_fd, F_SETFD, FD_CLOEXEC); |
54 | |
55 | |
55 | /* re-register interest in fds */ |
56 | /* re-register interest in fds */ |
56 | for (fd = 0; fd < anfdmax; ++fd) |
57 | for (fd = 0; fd < anfdmax; ++fd) |
57 | if (anfds [fd].wev) |
58 | if (anfds [fd].events)//D |
58 | epoll_modify (fd, EV_NONE, anfds [fd].wev); |
59 | epoll_modify (fd, EV_NONE, anfds [fd].events); |
59 | } |
60 | } |
60 | |
61 | |
61 | static struct epoll_event *events; |
62 | static struct epoll_event *events; |
62 | static int eventmax; |
63 | static int eventmax; |
63 | |
64 | |
|
|
65 | static void |
64 | static void epoll_poll (ev_tstamp timeout) |
66 | epoll_poll (ev_tstamp timeout) |
65 | { |
67 | { |
66 | int eventcnt = epoll_wait (epoll_fd, events, eventmax, ceil (timeout * 1000.)); |
68 | int eventcnt = epoll_wait (epoll_fd, events, eventmax, ceil (timeout * 1000.)); |
67 | int i; |
69 | int i; |
68 | |
70 | |
69 | if (eventcnt < 0) |
71 | if (eventcnt < 0) |
… | |
… | |
83 | eventmax += eventmax >> 1; |
85 | eventmax += eventmax >> 1; |
84 | events = malloc (sizeof (struct epoll_event) * eventmax); |
86 | events = malloc (sizeof (struct epoll_event) * eventmax); |
85 | } |
87 | } |
86 | } |
88 | } |
87 | |
89 | |
|
|
90 | static void |
88 | void epoll_init (int flags) |
91 | epoll_init (int flags) |
89 | { |
92 | { |
90 | epoll_fd = epoll_create (256); |
93 | epoll_fd = epoll_create (256); |
91 | |
94 | |
92 | if (epoll_fd < 0) |
95 | if (epoll_fd < 0) |
93 | return; |
96 | return; |
… | |
… | |
100 | method_poll = epoll_poll; |
103 | method_poll = epoll_poll; |
101 | |
104 | |
102 | eventmax = 64; /* intiial number of events receivable per poll */ |
105 | eventmax = 64; /* intiial number of events receivable per poll */ |
103 | events = malloc (sizeof (struct epoll_event) * eventmax); |
106 | events = malloc (sizeof (struct epoll_event) * eventmax); |
104 | } |
107 | } |
|
|
108 | |