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

Comparing libev/ev_poll.c (file contents):
Revision 1.5 by root, Sun Nov 4 18:29:44 2007 UTC vs.
Revision 1.7 by root, Tue Nov 6 00:10:04 2007 UTC

40 40
41static void 41static void
42poll_modify (EV_P_ int fd, int oev, int nev) 42poll_modify (EV_P_ int fd, int oev, int nev)
43{ 43{
44 int idx; 44 int idx;
45
46 if (oev == nev)
47 return;
48
45 array_needsize (pollidxs, pollidxmax, fd + 1, pollidx_init); 49 array_needsize (pollidxs, pollidxmax, fd + 1, pollidx_init);
46 50
47 idx = pollidxs [fd]; 51 idx = pollidxs [fd];
48 52
49 if (idx < 0) /* need to allocate a new pollfd */ 53 if (idx < 0) /* need to allocate a new pollfd */
69} 73}
70 74
71static void 75static void
72poll_poll (EV_P_ ev_tstamp timeout) 76poll_poll (EV_P_ ev_tstamp timeout)
73{ 77{
78 int i;
74 int res = poll (polls, pollcnt, ceil (timeout * 1000.)); 79 int res = poll (polls, pollcnt, ceil (timeout * 1000.));
75 80
76 if (res > 0) 81 if (res < 0)
77 {
78 int i;
79
80 for (i = 0; i < pollcnt; ++i)
81 fd_event (
82 EV_A_
83 polls [i].fd,
84 (polls [i].revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0)
85 | (polls [i].revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0)
86 );
87 }
88 else if (res < 0)
89 { 82 {
90 if (errno == EBADF) 83 if (errno == EBADF)
91 fd_ebadf (EV_A); 84 fd_ebadf (EV_A);
92 else if (errno == ENOMEM) 85 else if (errno == ENOMEM && !syserr_cb)
93 fd_enomem (EV_A); 86 fd_enomem (EV_A);
87 else if (errno != EINTR)
88 syserr ();
89
90 return;
94 } 91 }
92
93 for (i = 0; i < pollcnt; ++i)
94 fd_event (
95 EV_A_
96 polls [i].fd,
97 (polls [i].revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0)
98 | (polls [i].revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0)
99 );
95} 100}
96 101
97static int 102static int
98poll_init (EV_P_ int flags) 103poll_init (EV_P_ int flags)
99{ 104{
108} 113}
109 114
110static void 115static void
111poll_destroy (EV_P) 116poll_destroy (EV_P)
112{ 117{
113 free (pollidxs); 118 ev_free (pollidxs);
114 free (polls); 119 ev_free (polls);
115} 120}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines