diff options
author | Jens Axboe <axboe@kernel.dk> | 2019-10-24 16:34:31 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-10-24 16:34:31 -0600 |
commit | 1c8734fd8d851227e6da997c731f9aaa2f0d62f9 (patch) | |
tree | b4ca45aac78fdacf5c10c7d4af48ff98f3a798fa | |
parent | 5a9ab8de4cc71d1639fb19cd1cdf8b2067470c08 (diff) | |
download | liburing-1c8734fd8d851227e6da997c731f9aaa2f0d62f9.tar.gz liburing-1c8734fd8d851227e6da997c731f9aaa2f0d62f9.tar.bz2 |
test/send_recvmsg: ensure we exit
We may never get the data from the socket read, and this requires
someone to SIGINT the test. Let's quit after 1 second if we haven't
received anything. If the test is actually hung, the alive worker
detection will catch it.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | test/send_recvmsg.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/send_recvmsg.c b/test/send_recvmsg.c index 9b67b61..956fcfb 100644 --- a/test/send_recvmsg.c +++ b/test/send_recvmsg.c @@ -18,6 +18,11 @@ static char str[] = "This is a test of sendmsg and recvmsg over io_uring!"; #define PORT 10200 #define HOST "127.0.0.1" +static void sig_alrm(int sig) +{ + exit(0); +} + static int do_recvmsg(void) { struct sockaddr_in saddr; @@ -32,6 +37,8 @@ static int do_recvmsg(void) struct io_uring_sqe *sqe; int sockfd, ret; + signal(SIGALRM, sig_alrm); + ret = io_uring_queue_init(1, &ring, 0); if (ret) { printf("queue init fail\n"); @@ -69,6 +76,9 @@ static int do_recvmsg(void) goto err; } + /* we may never get the data, ensure we exit */ + alarm(1); + ret = io_uring_wait_cqe(&ring, &cqe); if (cqe->res < 0) { printf("failed cqe: %d\n", cqe->res); |