Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3749012ybl; Tue, 20 Aug 2019 01:31:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLKChGlACAsl/yocsOfEiHWMjUID04ZzsLsLZxS4uHlrX4kIlAOTz9Q4c83qfjbzobeyhO X-Received: by 2002:a62:b408:: with SMTP id h8mr28067069pfn.46.1566289860209; Tue, 20 Aug 2019 01:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566289860; cv=none; d=google.com; s=arc-20160816; b=DV3eRtshZCdamHWFljQDxUNKQ1xtBzeZEQ8IGR4tTpDES+XkH/oUsars2RR+5BQyhv HGQrHc8KeUnzlSj2EZOnxsXyk/2VwBP/MHQqbNmzldHvQP041rc7HXVwP82kZRjJi2xr BgtbkkMFb2M58DKXz2wNtukWpItrsaj23K4GJprOpxAt2bECYUqTAAcaAW4WaqTNMYiz 9Q1hGz3KoMt2EPAgWAhj0JPj/LYuWh4DBgIhUu2lHYwtDEQ0JYec/hBmV+Z0uJ3K5sw6 YSLPkZnGTtkaJdlmlL9bnwq51oB6DWOBZpAJvgd+e9+omtr97hEBKvPt8qRlz7gvKaN0 8v2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QNtsR2CKhTUmkIWTRhmFtchk7eHoDT8mwJbfUVDz+rM=; b=afNnsFxkTD2otiWahVt0rWW+R4vdstxNOPs6tl32i9P5I4NXjzgdwglppP8I0xc1Yp oDGQG+f5su1ZsRiiM/UZpH+4cJRr42tVtC2kvt9m43cgH2bwK8xNPkKpPDZACC8/ugIY NPURwSaRdb/SkA/bcG6wxUE0zOvPRk5VTGtVdf9hTfYNNX6BBlzD+syZLW6h7YloHF37 qoW9gPp2IX5CoS6pr+HtlG5rkDlQl7xjHz5dvg4G+ZU+jZvsZLNoo3kQ0iwg2MrJUdxN RW3UG9bGB+/nqE08GbPWT3YYIDgzo6IMqkGNjkeJ8WdkEEcplHkORfY8lqTT8Dgl8gW4 TmPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si11859635pls.116.2019.08.20.01.30.45; Tue, 20 Aug 2019 01:31:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729478AbfHTI2a (ORCPT + 99 others); Tue, 20 Aug 2019 04:28:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48928 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfHTI2a (ORCPT ); Tue, 20 Aug 2019 04:28:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 368D4300180E; Tue, 20 Aug 2019 08:28:30 +0000 (UTC) Received: from localhost (ovpn-117-123.ams2.redhat.com [10.36.117.123]) by smtp.corp.redhat.com (Postfix) with ESMTP id A490C5D9D5; Tue, 20 Aug 2019 08:28:29 +0000 (UTC) Date: Tue, 20 Aug 2019 09:28:28 +0100 From: Stefan Hajnoczi To: Stefano Garzarella Cc: netdev@vger.kernel.org, kvm@vger.kernel.org, Dexuan Cui , virtualization@lists.linux-foundation.org, "David S. Miller" , Jorgen Hansen , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 11/11] vsock_test: wait for the remote to close the connection Message-ID: <20190820082828.GA9855@stefanha-x1.localdomain> References: <20190801152541.245833-1-sgarzare@redhat.com> <20190801152541.245833-12-sgarzare@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0F1p//8PRICkK4MW" Content-Disposition: inline In-Reply-To: <20190801152541.245833-12-sgarzare@redhat.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 20 Aug 2019 08:28:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =3D epoll_create1(0); > + if (epollfd =3D=3D -1) { > + perror("epoll_create1"); > + exit(EXIT_FAILURE); > + } > + > + ev.events =3D EPOLLRDHUP | EPOLLHUP; > + ev.data.fd =3D fd; > + if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) =3D=3D -1) { > + perror("epoll_ctl"); > + exit(EXIT_FAILURE); > + } > + > + nfds =3D epoll_wait(epollfd, &ev, 1, TIMEOUT * 1000); > + if (nfds =3D=3D -1) { > + perror("epoll_wait"); > + exit(EXIT_FAILURE); > + } > + > + if (nfds =3D=3D 0) { > + fprintf(stderr, "epoll_wait timed out\n"); > + exit(EXIT_FAILURE); > + } > + > + assert(nfds =3D=3D 1); > + assert(ev.events & (EPOLLRDHUP | EPOLLHUP)); > + assert(ev.data.fd =3D=3D 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 stru= ct test_opts *opts) > =20 > control_expectln("CLOSED"); > =20 > + /* 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. --0F1p//8PRICkK4MW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAl1brywACgkQnKSrs4Gr c8he/ggAs417RXraEFHwXmiz0k0MOniGzChyB01FvERBmU5Q3lFaA9yTm3CfBmeM dsWmGaQ+UcV0T+BvE+Y+oUV6lspdjNMX2D02+Xfl9SNwKh1CGxmipyRSsITapVXg 9wFwZzD/+IJ6bSzUxyYpPZhb0n1cZNnMnB0hpTFGSvJMrbk/phSv3NVd7LrJVuM2 uTYaoaFXQ4QTPnnVO7JonGbeHJuinIleByziLGaCCDgeEan9gf48eQPsN1Pvhf+g /YjmlJEqbpekU8wpwggoRFZ9UlkbiLhbCtZdvE7Kzj9PaS1DSF+AWLdL9fOa+N1K jNvf8bhepUvIw0MgGeM/Az9vsHfFZw== =E1TQ -----END PGP SIGNATURE----- --0F1p//8PRICkK4MW--