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.
@@ -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);
