… | |
… | |
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 | static void |
49 | epoll_postfork_child (EV_P) |
|
|
50 | { |
|
|
51 | int fd; |
|
|
52 | |
|
|
53 | epoll_fd = epoll_create (256); |
|
|
54 | fcntl (epoll_fd, F_SETFD, FD_CLOEXEC); |
|
|
55 | |
|
|
56 | /* re-register interest in fds */ |
|
|
57 | for (fd = 0; fd < anfdmax; ++fd) |
|
|
58 | if (anfds [fd].events)//D |
|
|
59 | epoll_modify (EV_A_ fd, EV_NONE, anfds [fd].events); |
|
|
60 | } |
|
|
61 | |
|
|
62 | static void |
|
|
63 | epoll_poll (EV_P_ ev_tstamp timeout) |
49 | epoll_poll (EV_P_ ev_tstamp timeout) |
64 | { |
50 | { |
65 | int eventcnt = epoll_wait (epoll_fd, epoll_events, epoll_eventmax, ceil (timeout * 1000.)); |
51 | int eventcnt = epoll_wait (epoll_fd, epoll_events, epoll_eventmax, ceil (timeout * 1000.)); |
66 | int i; |
52 | int i; |
67 | |
53 | |
… | |
… | |
103 | epoll_events = malloc (sizeof (struct epoll_event) * epoll_eventmax); |
89 | epoll_events = malloc (sizeof (struct epoll_event) * epoll_eventmax); |
104 | |
90 | |
105 | return EVMETHOD_EPOLL; |
91 | return EVMETHOD_EPOLL; |
106 | } |
92 | } |
107 | |
93 | |
|
|
94 | static void |
|
|
95 | epoll_destroy (EV_P) |
|
|
96 | { |
|
|
97 | close (epoll_fd); |
|
|
98 | |
|
|
99 | free (epoll_events); |
|
|
100 | } |
|
|
101 | |
|
|
102 | static void |
|
|
103 | epoll_fork (EV_P) |
|
|
104 | { |
|
|
105 | int fd; |
|
|
106 | |
|
|
107 | epoll_fd = epoll_create (256); |
|
|
108 | fcntl (epoll_fd, F_SETFD, FD_CLOEXEC); |
|
|
109 | |
|
|
110 | fd_rearm_all (); |
|
|
111 | } |
|
|
112 | |