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

Comparing libev/ev_linuxaio.c (file contents):
Revision 1.21 by root, Mon Jun 24 20:44:15 2019 UTC vs.
Revision 1.22 by root, Mon Jun 24 21:27:57 2019 UTC

125 /*int inuse;*/ 125 /*int inuse;*/
126} *ANIOCBP; 126} *ANIOCBP;
127 127
128inline_size 128inline_size
129void 129void
130linuxaio_array_needsize_iocbp (ANIOCBP *base, int count) 130linuxaio_array_needsize_iocbp (ANIOCBP *base, int offset, int count)
131{ 131{
132 /* TODO: quite the overhead to allocate every iocb separately, maybe use our own alocator? */ 132 /* TODO: quite the overhead to allocate every iocb separately, maybe use our own alocator? */
133 while (count--) 133 while (count--)
134 { 134 {
135 *base = (ANIOCBP)ev_malloc (sizeof (**base)); 135 ANIOCBP iocb = (ANIOCBP)ev_malloc (sizeof (*iocb));
136 /* TODO: full zero initialize required? */ 136
137 /* full zero initialise is probably not required at the moment, but
138 * this is not well documented, so we better do it.
139 */
137 memset (*base, 0, sizeof (**base)); 140 memset (iocb, 0, sizeof (*iocb));
138 /* would be nice to initialize fd/data as well, but array_needsize API doesn't support that */ 141
139 (*base)->io.aio_lio_opcode = IOCB_CMD_POLL; 142 iocb->io.aio_lio_opcode = IOCB_CMD_POLL;
140 ++base; 143 iocb->io.aio_data = offset;
144 iocb->io.aio_fildes = offset;
145
146 base [offset++] = iocb;
141 } 147 }
142} 148}
143 149
144ecb_cold 150ecb_cold
145static void 151static void
153 159
154static void 160static void
155linuxaio_modify (EV_P_ int fd, int oev, int nev) 161linuxaio_modify (EV_P_ int fd, int oev, int nev)
156{ 162{
157 array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp); 163 array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp);
158 struct aniocb *iocb = linuxaio_iocbps [fd]; 164 ANIOCBP iocb = linuxaio_iocbps [fd];
159 165
160#if EPOLL_FALLBACK 166#if EPOLL_FALLBACK
161 if (iocb->io.aio_reqprio < 0) 167 if (iocb->io.aio_reqprio < 0)
162 { 168 {
163 epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0); 169 epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0);
168 if (iocb->io.aio_buf) 174 if (iocb->io.aio_buf)
169 evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0); /* always returns an error relevant kernels */ 175 evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0); /* always returns an error relevant kernels */
170 176
171 if (nev) 177 if (nev)
172 { 178 {
173 iocb->io.aio_data = fd;
174 iocb->io.aio_fildes = fd;
175 iocb->io.aio_buf = 179 iocb->io.aio_buf =
176 (nev & EV_READ ? POLLIN : 0) 180 (nev & EV_READ ? POLLIN : 0)
177 | (nev & EV_WRITE ? POLLOUT : 0); 181 | (nev & EV_WRITE ? POLLOUT : 0);
178 182
179 /* queue iocb up for io_submit */ 183 /* queue iocb up for io_submit */
180 /* this assumes we only ever get one call per fd per loop iteration */ 184 /* this assumes we only ever get one call per fd per loop iteration */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines