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.19 by root, Sun Nov 4 23:14:11 2007 UTC vs.
Revision 1.20 by root, Tue Nov 6 00:10:04 2007 UTC

49} 49}
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 eventcnt = epoll_wait (epoll_fd, epoll_events, epoll_eventmax, ceil (timeout * 1000.)); 55 int eventcnt = epoll_wait (epoll_fd, epoll_events, epoll_eventmax, ceil (timeout * 1000.));
55 int i;
56 56
57 if (eventcnt < 0) 57 if (eventcnt < 0)
58 {
59 if (errno != EINTR)
60 syserr ();
61
58 return; 62 return;
63 }
59 64
60 for (i = 0; i < eventcnt; ++i) 65 for (i = 0; i < eventcnt; ++i)
61 fd_event ( 66 fd_event (
62 EV_A_ 67 EV_A_
63 epoll_events [i].data.u64, 68 epoll_events [i].data.u64,
66 ); 71 );
67 72
68 /* if the receive array was full, increase its size */ 73 /* if the receive array was full, increase its size */
69 if (expect_false (eventcnt == epoll_eventmax)) 74 if (expect_false (eventcnt == epoll_eventmax))
70 { 75 {
71 free (epoll_events); 76 ev_free (epoll_events);
72 epoll_eventmax = array_roundsize (epoll_events, epoll_eventmax << 1); 77 epoll_eventmax = array_roundsize (epoll_events, epoll_eventmax << 1);
73 epoll_events = malloc (sizeof (struct epoll_event) * epoll_eventmax); 78 epoll_events = ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
74 } 79 }
75} 80}
76 81
77static int 82static int
78epoll_init (EV_P_ int flags) 83epoll_init (EV_P_ int flags)
87 method_fudge = 1e-3; /* needed to compensate for epoll returning early */ 92 method_fudge = 1e-3; /* needed to compensate for epoll returning early */
88 method_modify = epoll_modify; 93 method_modify = epoll_modify;
89 method_poll = epoll_poll; 94 method_poll = epoll_poll;
90 95
91 epoll_eventmax = 64; /* intiial number of events receivable per poll */ 96 epoll_eventmax = 64; /* intiial number of events receivable per poll */
92 epoll_events = malloc (sizeof (struct epoll_event) * epoll_eventmax); 97 epoll_events = ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
93 98
94 return EVMETHOD_EPOLL; 99 return EVMETHOD_EPOLL;
95} 100}
96 101
97static void 102static void
98epoll_destroy (EV_P) 103epoll_destroy (EV_P)
99{ 104{
100 close (epoll_fd); 105 close (epoll_fd);
101 106
102 free (epoll_events); 107 ev_free (epoll_events);
103} 108}
104 109
105static void 110static void
106epoll_fork (EV_P) 111epoll_fork (EV_P)
107{ 112{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines