Update POLL API

Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Jens Axboe
2019-01-17 14:24:28 -07:00
parent 79a7d3a3f6
commit 768d4559d0
3 changed files with 10 additions and 24 deletions

View File

@@ -27,6 +27,7 @@ struct io_uring_sqe {
union { union {
__kernel_rwf_t rw_flags; __kernel_rwf_t rw_flags;
__u32 fsync_flags; __u32 fsync_flags;
__u16 poll_events;
}; };
__u64 user_data; /* data to be passed back at completion time */ __u64 user_data; /* data to be passed back at completion time */
union { union {

View File

@@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <sys/wait.h> #include <sys/wait.h>
@@ -36,14 +37,10 @@ int main(int argc, char *argv[])
printf("child: get sqe failed\n"); printf("child: get sqe failed\n");
return 1; return 1;
} }
memset(sqe, 0, sizeof(*sqe));
sqe->opcode = IORING_OP_POLL; sqe->opcode = IORING_OP_POLL;
sqe->flags = 0;
sqe->ioprio = 0;
sqe->fd = pipe1[0]; sqe->fd = pipe1[0];
sqe->addr = POLLIN; sqe->poll_events = POLLIN;
sqe->off = 0;
sqe->len = 0;
sqe->buf_index = 0;
sqe->user_data = addr = (unsigned long) &sqe; sqe->user_data = addr = (unsigned long) &sqe;
ret = io_uring_submit(&ring); ret = io_uring_submit(&ring);
@@ -57,14 +54,9 @@ int main(int argc, char *argv[])
printf("child: get sqe failed\n"); printf("child: get sqe failed\n");
return 1; return 1;
} }
memset(sqe, 0, sizeof(*sqe));
sqe->opcode = IORING_OP_POLL_CANCEL; sqe->opcode = IORING_OP_POLL_CANCEL;
sqe->flags = 0;
sqe->ioprio = 0;
sqe->fd = 0;
sqe->addr = addr; sqe->addr = addr;
sqe->off = 0;
sqe->len = 0;
sqe->buf_index = 0;
sqe->user_data = (unsigned long) &sqe; sqe->user_data = (unsigned long) &sqe;
ret = io_uring_submit(&ring); ret = io_uring_submit(&ring);

View File

@@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <sys/wait.h> #include <sys/wait.h>
@@ -47,14 +48,10 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
memset(sqe, 0, sizeof(*sqe));
sqe->opcode = IORING_OP_POLL; sqe->opcode = IORING_OP_POLL;
sqe->flags = 0;
sqe->ioprio = 0;
sqe->fd = pipe1[0]; sqe->fd = pipe1[0];
sqe->addr = POLLIN; sqe->poll_events = POLLIN;
sqe->off = 0;
sqe->len = 0;
sqe->buf_index = 0;
sqe->user_data = (unsigned long) &sqe; sqe->user_data = (unsigned long) &sqe;
ret = io_uring_submit(&cring); ret = io_uring_submit(&cring);
@@ -98,14 +95,10 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
memset(sqe, 0, sizeof(*sqe));
sqe->opcode = IORING_OP_POLL; sqe->opcode = IORING_OP_POLL;
sqe->flags = 0;
sqe->ioprio = 0;
sqe->fd = pipe2[0]; sqe->fd = pipe2[0];
sqe->addr = POLLIN; sqe->poll_events = POLLIN;
sqe->off = 0;
sqe->len = 0;
sqe->buf_index = 0;
sqe->user_data = (unsigned long) &sqe; sqe->user_data = (unsigned long) &sqe;
ret = io_uring_submit(&pring); ret = io_uring_submit(&pring);