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.2 by root, Thu Jun 20 23:14:54 2019 UTC vs.
Revision 1.5 by root, Fri Jun 21 03:41:40 2019 UTC

51/*****************************************************************************/ 51/*****************************************************************************/
52/* syscall wrapdadoop */ 52/* syscall wrapdadoop */
53 53
54#include <sys/syscall.h> /* no glibc wrappers */ 54#include <sys/syscall.h> /* no glibc wrappers */
55 55
56/* aio_abi.h is not verioned in any way, so we cannot test for its existance */ 56/* aio_abi.h is not versioned in any way, so we cannot test for its existance */
57#define IOCB_CMD_POLL 5 57#define IOCB_CMD_POLL 5
58 58
59/* taken from linux/fs/aio.c */ 59/* taken from linux/fs/aio.c */
60#define AIO_RING_MAGIC 0xa10a10a1 60#define AIO_RING_MAGIC 0xa10a10a1
61#define AIO_RING_INCOMPAT_FEATURES 0 61#define AIO_RING_INCOMPAT_FEATURES 0
148{ 148{
149 array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp); 149 array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp);
150 struct aniocb *iocb = linuxaio_iocbps [fd]; 150 struct aniocb *iocb = linuxaio_iocbps [fd];
151 151
152 if (iocb->io.aio_buf) 152 if (iocb->io.aio_buf)
153 ev_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0); 153 ev_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0); /* always returns an error relevant kernels */
154 154
155 if (nev) 155 if (nev)
156 { 156 {
157 iocb->io.aio_data = fd; 157 iocb->io.aio_data = fd;
158 iocb->io.aio_fildes = fd; 158 iocb->io.aio_fildes = fd;
282 /* This happens when the ring buffer is full, at least. I assume this means 282 /* This happens when the ring buffer is full, at least. I assume this means
283 * that the event was queued synchronously during io_submit, and thus 283 * that the event was queued synchronously during io_submit, and thus
284 * the buffer overflowd. 284 * the buffer overflowd.
285 * In this case, we just try next loop iteration. 285 * In this case, we just try next loop iteration.
286 */ 286 */
287 memcpy (linuxaio_submits, linuxaio_submits + submitted, (linuxaio_submitcnt - submitted) * sizeof (*linuxaio_submits)); 287 memmove (linuxaio_submits, linuxaio_submits + submitted, (linuxaio_submitcnt - submitted) * sizeof (*linuxaio_submits));
288 linuxaio_submitcnt -= submitted; 288 linuxaio_submitcnt -= submitted;
289 timeout = 0; 289 timeout = 0;
290 break; 290 break;
291 } 291 }
292 else 292 else
311 /* would be great to have a nice test for IOCB_CMD_POLL instead */ 311 /* would be great to have a nice test for IOCB_CMD_POLL instead */
312 /* also: test some semi-common fd types, such as files and ttys in recommended_backends */ 312 /* also: test some semi-common fd types, such as files and ttys in recommended_backends */
313 if (ev_linux_version () < 0x041200) /* 4.18 introduced IOCB_CMD_POLL */ 313 if (ev_linux_version () < 0x041200) /* 4.18 introduced IOCB_CMD_POLL */
314 return 0; 314 return 0;
315 315
316 linuxaio_ctx = 0;
316 if (ev_io_setup (EV_LINUXAIO_DEPTH, &linuxaio_ctx) < 0) 317 if (ev_io_setup (EV_LINUXAIO_DEPTH, &linuxaio_ctx) < 0)
317 return 0; 318 return 0;
318 319
319 backend_modify = linuxaio_modify; 320 backend_modify = linuxaio_modify;
320 backend_poll = linuxaio_poll; 321 backend_poll = linuxaio_poll;
342linuxaio_fork (EV_P) 343linuxaio_fork (EV_P)
343{ 344{
344 /* TODO: verify and test */ 345 /* TODO: verify and test */
345 linuxaio_destroy (EV_A); 346 linuxaio_destroy (EV_A);
346 347
348 linuxaio_ctx = 0;
347 while (ev_io_setup (EV_LINUXAIO_DEPTH, &linuxaio_ctx) < 0) 349 while (ev_io_setup (EV_LINUXAIO_DEPTH, &linuxaio_ctx) < 0)
348 ev_syserr ("(libev) io_setup"); 350 ev_syserr ("(libev) io_setup");
349 351
350 fd_rearm_all (EV_A); 352 fd_rearm_all (EV_A);
351} 353}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines