ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_epoll.c
(Generate patch)

Comparing libev/ev_epoll.c (file contents):
Revision 1.20 by root, Tue Nov 6 00:10:04 2007 UTC vs.
Revision 1.23 by root, Tue Nov 6 16:51:20 2007 UTC

50 50
51static void 51static void
52epoll_poll (EV_P_ ev_tstamp timeout) 52epoll_poll (EV_P_ ev_tstamp timeout)
53{ 53{
54 int i; 54 int i;
55 int eventcnt = epoll_wait (epoll_fd, epoll_events, epoll_eventmax, ceil (timeout * 1000.)); 55 int eventcnt = epoll_wait (epoll_fd, epoll_events, epoll_eventmax, (int)ceil (timeout * 1000.));
56 56
57 if (eventcnt < 0) 57 if (eventcnt < 0)
58 { 58 {
59 if (errno != EINTR) 59 if (errno != EINTR)
60 syserr (); 60 syserr ("(libev) epoll_wait");
61 61
62 return; 62 return;
63 } 63 }
64 64
65 for (i = 0; i < eventcnt; ++i) 65 for (i = 0; i < eventcnt; ++i)
73 /* if the receive array was full, increase its size */ 73 /* if the receive array was full, increase its size */
74 if (expect_false (eventcnt == epoll_eventmax)) 74 if (expect_false (eventcnt == epoll_eventmax))
75 { 75 {
76 ev_free (epoll_events); 76 ev_free (epoll_events);
77 epoll_eventmax = array_roundsize (epoll_events, epoll_eventmax << 1); 77 epoll_eventmax = array_roundsize (epoll_events, epoll_eventmax << 1);
78 epoll_events = ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); 78 epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
79 } 79 }
80} 80}
81 81
82static int 82static int
83epoll_init (EV_P_ int flags) 83epoll_init (EV_P_ int flags)
92 method_fudge = 1e-3; /* needed to compensate for epoll returning early */ 92 method_fudge = 1e-3; /* needed to compensate for epoll returning early */
93 method_modify = epoll_modify; 93 method_modify = epoll_modify;
94 method_poll = epoll_poll; 94 method_poll = epoll_poll;
95 95
96 epoll_eventmax = 64; /* intiial number of events receivable per poll */ 96 epoll_eventmax = 64; /* intiial number of events receivable per poll */
97 epoll_events = ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); 97 epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
98 98
99 return EVMETHOD_EPOLL; 99 return EVMETHOD_EPOLL;
100} 100}
101 101
102static void 102static void
108} 108}
109 109
110static void 110static void
111epoll_fork (EV_P) 111epoll_fork (EV_P)
112{ 112{
113 close (epoll_fd);
114
113 epoll_fd = epoll_create (256); 115 while ((epoll_fd = epoll_create (256)) < 0)
116 syserr ("(libev) epoll_create");
117
114 fcntl (epoll_fd, F_SETFD, FD_CLOEXEC); 118 fcntl (epoll_fd, F_SETFD, FD_CLOEXEC);
115 119
116 fd_rearm_all (EV_A); 120 fd_rearm_all (EV_A);
117} 121}
118 122

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines