From: Stefan Hajnoczi <stefanha@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: netdev@vger.kernel.org, kvm@vger.kernel.org,
Dexuan Cui <decui@microsoft.com>,
virtualization@lists.linux-foundation.org,
"David S. Miller" <davem@davemloft.net>,
Jorgen Hansen <jhansen@vmware.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 11/11] vsock_test: wait for the remote to close the connection
Date: Tue, 20 Aug 2019 09:28:28 +0100 [thread overview]
Message-ID: <20190820082828.GA9855@stefanha-x1.localdomain> (raw)
In-Reply-To: <20190801152541.245833-12-sgarzare@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1678 bytes --]
On Thu, Aug 01, 2019 at 05:25:41PM +0200, Stefano Garzarella wrote:
> +/* Wait for the remote to close the connection */
> +void vsock_wait_remote_close(int fd)
> +{
> + struct epoll_event ev;
> + int epollfd, nfds;
> +
> + epollfd = epoll_create1(0);
> + if (epollfd == -1) {
> + perror("epoll_create1");
> + exit(EXIT_FAILURE);
> + }
> +
> + ev.events = EPOLLRDHUP | EPOLLHUP;
> + ev.data.fd = fd;
> + if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) {
> + perror("epoll_ctl");
> + exit(EXIT_FAILURE);
> + }
> +
> + nfds = epoll_wait(epollfd, &ev, 1, TIMEOUT * 1000);
> + if (nfds == -1) {
> + perror("epoll_wait");
> + exit(EXIT_FAILURE);
> + }
> +
> + if (nfds == 0) {
> + fprintf(stderr, "epoll_wait timed out\n");
> + exit(EXIT_FAILURE);
> + }
> +
> + assert(nfds == 1);
> + assert(ev.events & (EPOLLRDHUP | EPOLLHUP));
> + assert(ev.data.fd == fd);
> +
> + close(epollfd);
> +}
Please use timeout_begin()/timeout_end() so that the test cannot hang.
> diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
> index 64adf45501ca..a664675bec5a 100644
> --- a/tools/testing/vsock/vsock_test.c
> +++ b/tools/testing/vsock/vsock_test.c
> @@ -84,6 +84,11 @@ static void test_stream_client_close_server(const struct test_opts *opts)
>
> control_expectln("CLOSED");
>
> + /* Wait for the remote to close the connection, before check
> + * -EPIPE error on send.
> + */
> + vsock_wait_remote_close(fd);
Is control_expectln("CLOSED") still necessary now that we're waiting for
the poll event? The control message was an attempt to wait until the
other side closed the socket.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-08-20 8:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 15:25 [PATCH v2 00/11] VSOCK: add vsock_test test suite Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 01/11] VSOCK: fix header include in vsock_diag_test Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 02/11] VSOCK: add SPDX identifiers to vsock tests Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 03/11] VSOCK: extract utility functions from vsock_diag_test.c Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 04/11] VSOCK: extract connect/accept " Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 05/11] VSOCK: add full barrier between test cases Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 06/11] VSOCK: add send_byte()/recv_byte() test utilities Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 07/11] VSOCK: add AF_VSOCK test cases Stefano Garzarella
2019-10-09 10:03 ` Stefano Garzarella
2019-10-09 15:15 ` Stefan Hajnoczi
2019-10-10 8:47 ` Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 08/11] VSOCK: add vsock_get_local_cid() test utility Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 09/11] vsock_test: add --transport parameter Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 10/11] vsock_test: skip read() in test_stream*close tests on a VMCI host Stefano Garzarella
2019-08-01 15:53 ` Sergei Shtylyov
2019-08-01 15:58 ` Stefano Garzarella
2019-08-20 8:32 ` Stefan Hajnoczi
2019-08-22 10:08 ` Stefano Garzarella
2019-08-01 15:25 ` [PATCH v2 11/11] vsock_test: wait for the remote to close the connection Stefano Garzarella
2019-08-20 8:28 ` Stefan Hajnoczi [this message]
2019-08-22 9:15 ` Stefano Garzarella
2019-08-23 10:09 ` Stefan Hajnoczi
2019-08-01 16:16 ` [PATCH v2 00/11] VSOCK: add vsock_test test suite Dexuan Cui
2019-08-02 7:55 ` Stefano Garzarella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190820082828.GA9855@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=jhansen@vmware.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).