Ignore:
Timestamp:
Jul 27, 2020, 1:32:39 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f3ed2af
Parents:
5b15c4f
Message:

io_uring example now uses O_DIRECT to test polling support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/io_uring.c

    r5b15c4f ra86b1b85  
     1#define _GNU_SOURCE
     2
    13#include <fcntl.h>
    24#include <liburing.h>
    35#include <stdio.h>
     6#include <string.h>
    47#include <unistd.h>
    58
     
    1215      }
    1316
    14       int fd = open(argv[1], 0);
     17      int fd = open(argv[1], O_DIRECT);
    1518      if(fd < 0) {
    1619            printf("Could not open file %s.\n", argv[1]);
     
    2326
    2427      /* init liburing */
    25       io_uring_queue_init(256, &ring, 0);
     28      io_uring_queue_init(256, &ring, IORING_SETUP_IOPOLL);
    2629
    2730      /* declare required structs */
     
    4043      /* wait for the sqe to complete */
    4144      int ret = io_uring_wait_cqe(&ring, &cqe);
    42      
     45
    4346      /* read and process cqe event */
    4447      if(ret == 0) {
     
    4952            if(len > 0) {
    5053                  printf("%.*s", len, out);
     54            }
     55            else if( len < 0 ) {
     56                  fprintf(stderr, "readv returned error : %s\n", strerror(-len));
    5157            }
    5258      }
Note: See TracChangeset for help on using the changeset viewer.