diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index 15dff0541..3ec1061c5 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -438,6 +438,8 @@ static int _sock_flush(struct spdk_sock *sock) { struct spdk_posix_sock *psock = __posix_sock(sock); + struct msghdr msg = {}; + int flags; struct iovec iovs[IOV_BATCH_SIZE]; int iovcnt; int retval; @@ -488,7 +490,10 @@ _sock_flush(struct spdk_sock *sock) } /* Perform the vectored write */ - rc = writev(psock->fd, iovs, iovcnt); + msg.msg_iov = iovs; + msg.msg_iovlen = iovcnt; + flags = 0; + rc = sendmsg(psock->fd, &msg, flags); if (rc <= 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) { return 0; @@ -526,7 +531,7 @@ _sock_flush(struct spdk_sock *sock) req->internal.offset = 0; spdk_sock_request_pend(sock, req); - /* The writev syscall above isn't currently asynchronous, + /* The sendmsg syscall above isn't currently asynchronous, * so it's already done. */ retval = spdk_sock_request_put(sock, req, 0); diff --git a/test/unit/lib/sock/posix.c/posix_ut.c b/test/unit/lib/sock/posix.c/posix_ut.c index ae61d7cfd..b8a704043 100644 --- a/test/unit/lib/sock/posix.c/posix_ut.c +++ b/test/unit/lib/sock/posix.c/posix_ut.c @@ -86,9 +86,9 @@ flush(void) req2->cb_arg = &cb_arg2; /* Simple test - a request with a 2 element iovec - * that gets submitted in a single writev. */ + * that gets submitted in a single sendmsg. */ spdk_sock_request_queue(sock, req1); - MOCK_SET(writev, 64); + MOCK_SET(sendmsg, 64); cb_arg1 = false; rc = _sock_flush(sock); CU_ASSERT(rc == 0); @@ -98,7 +98,7 @@ flush(void) /* Two requests, where both can fully send. */ spdk_sock_request_queue(sock, req1); spdk_sock_request_queue(sock, req2); - MOCK_SET(writev, 128); + MOCK_SET(sendmsg, 128); cb_arg1 = false; cb_arg2 = false; rc = _sock_flush(sock); @@ -110,7 +110,7 @@ flush(void) /* Two requests. Only first one can send */ spdk_sock_request_queue(sock, req1); spdk_sock_request_queue(sock, req2); - MOCK_SET(writev, 64); + MOCK_SET(sendmsg, 64); cb_arg1 = false; cb_arg2 = false; rc = _sock_flush(sock); @@ -123,7 +123,7 @@ flush(void) /* One request. Partial send. */ spdk_sock_request_queue(sock, req1); - MOCK_SET(writev, 10); + MOCK_SET(sendmsg, 10); cb_arg1 = false; rc = _sock_flush(sock); CU_ASSERT(rc == 0); @@ -131,7 +131,7 @@ flush(void) CU_ASSERT(TAILQ_FIRST(&sock->queued_reqs) == req1); /* Do a second flush that partial sends again. */ - MOCK_SET(writev, 24); + MOCK_SET(sendmsg, 24); cb_arg1 = false; rc = _sock_flush(sock); CU_ASSERT(rc == 0); @@ -139,7 +139,7 @@ flush(void) CU_ASSERT(TAILQ_FIRST(&sock->queued_reqs) == req1); /* Flush the rest of the data */ - MOCK_SET(writev, 30); + MOCK_SET(sendmsg, 30); cb_arg1 = false; rc = _sock_flush(sock); CU_ASSERT(rc == 0);