summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/send_recvmsg.c10
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);