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

Comparing libev/ev_port.c (file contents):
Revision 1.4 by root, Fri Nov 23 05:13:49 2007 UTC vs.
Revision 1.5 by root, Fri Nov 23 19:13:33 2007 UTC

37 * once more silently being discarded. 37 * once more silently being discarded.
38 */ 38 */
39 if (!nev) 39 if (!nev)
40 { 40 {
41 if (oev) 41 if (oev)
42 port_dissociate (port_fd, PORT_SOURCE_FD, fd); 42 port_dissociate (backend_fd, PORT_SOURCE_FD, fd);
43 } 43 }
44 else if (0 > 44 else if (0 >
45 port_associate ( 45 port_associate (
46 port_fd, PORT_SOURCE_FD, fd, 46 backend_fd, PORT_SOURCE_FD, fd,
47 (nev & EV_READ ? POLLIN : 0) 47 (nev & EV_READ ? POLLIN : 0)
48 | (nev & EV_WRITE ? POLLOUT : 0), 48 | (nev & EV_WRITE ? POLLOUT : 0),
49 0 49 0
50 ) 50 )
51 ) 51 )
64 struct timespec ts; 64 struct timespec ts;
65 uint_t nget = 1; 65 uint_t nget = 1;
66 66
67 ts.tv_sec = (time_t)timeout; 67 ts.tv_sec = (time_t)timeout;
68 ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9; 68 ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9;
69 res = port_getn (port_fd, port_events, port_eventmax, &nget, &ts); 69 res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts);
70 70
71 if (res < 0) 71 if (res < 0)
72 { 72 {
73 if (errno != EINTR && errno != ETIME) 73 if (errno != EINTR && errno != ETIME)
74 syserr ("(libev) port_getn"); 74 syserr ("(libev) port_getn");
104 104
105static int 105static int
106port_init (EV_P_ int flags) 106port_init (EV_P_ int flags)
107{ 107{
108 /* Initalize the kernel queue */ 108 /* Initalize the kernel queue */
109 if ((port_fd = port_create ()) < 0) 109 if ((backend_fd = port_create ()) < 0)
110 return 0; 110 return 0;
111 111
112 fcntl (port_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ 112 fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
113 113
114 backend_fudge = 1e-3; /* needed to compensate for port_getn returning early */ 114 backend_fudge = 1e-3; /* needed to compensate for port_getn returning early */
115 backend_modify = port_modify; 115 backend_modify = port_modify;
116 backend_poll = port_poll; 116 backend_poll = port_poll;
117 117
122} 122}
123 123
124static void 124static void
125port_destroy (EV_P) 125port_destroy (EV_P)
126{ 126{
127 close (port_fd); 127 close (backend_fd);
128 128
129 ev_free (port_events); 129 ev_free (port_events);
130} 130}
131 131
132static void 132static void
133port_fork (EV_P) 133port_fork (EV_P)
134{ 134{
135 close (port_fd); 135 close (backend_fd);
136 136
137 while ((port_fd = port_create ()) < 0) 137 while ((backend_fd = port_create ()) < 0)
138 syserr ("(libev) port"); 138 syserr ("(libev) port");
139 139
140 fcntl (port_fd, F_SETFD, FD_CLOEXEC); 140 fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
141 141
142 /* re-register interest in fds */ 142 /* re-register interest in fds */
143 fd_rearm_all (EV_A); 143 fd_rearm_all (EV_A);
144} 144}
145 145

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines