From owner-freebsd-net@FreeBSD.ORG Sun Jun 19 09:44:07 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C20831065670; Sun, 19 Jun 2011 09:44:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 099628FC18; Sun, 19 Jun 2011 09:44:06 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p5J9i4lT073658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 19 Jun 2011 12:44:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p5J9i3NN095236; Sun, 19 Jun 2011 12:44:03 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p5J9i3HJ095235; Sun, 19 Jun 2011 12:44:03 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 19 Jun 2011 12:44:03 +0300 From: Kostik Belousov To: Mikolaj Golub Message-ID: <20110619094403.GD48734@deviant.kiev.zoral.com.ua> References: <86pqmhn1pf.fsf@kopusha.home.net> <20110614092303.GG48734@deviant.kiev.zoral.com.ua> <86k4cntwz2.fsf@in138.ua3> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FM5zcXyvfv2Qtj+b" Content-Disposition: inline In-Reply-To: <86k4cntwz2.fsf@in138.ua3> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-net@freebsd.org, Pawel Jakub Dawidek Subject: Re: Scenario to make recv(MSG_WAITALL) stuck X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jun 2011 09:44:07 -0000 --FM5zcXyvfv2Qtj+b Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 15, 2011 at 09:44:33AM +0300, Mikolaj Golub wrote: >=20 > On Tue, 14 Jun 2011 12:23:03 +0300 Kostik Belousov wrote: >=20 > KB> I do not understand what then happens for the recvfrom(2) call ? > KB> Would it get some error, or 0 as return and no data, or something el= se ? >=20 > It will wait for data below in another loop ("Now continue to read any da= ta > mbufs off of the head..."). >=20 > Elaborating, I would split soreceive_generic on three logical parts. >=20 > In the first (restart) part we block until some data are received and also > (without the patch) in the case of MSG_WAITALL if the buffer is big enoug= h we > block until all MSG_WAITALL request is received (actually it will spin in > "goto restart" loop until some condition becomes invalid). >=20 > The second part is some processing of received data and the third part is= a > "while" loop where data is copied to userspace and in the case of MSG_WAI= TALL > request if not all data is received to satisfy the request it also waits = for > this data. >=20 > My patch removes the condition in the first part in the case of MSG_WAITA= LL to > wait for all data if buffer is big enough. We always will wait for the re= st of > data in the third part. It might be not so effective, and this is my first > concern about the patch (although not big :-). Now I think that this part of the patch is right. The loop in the soreceive_generic() would behave as I would expect it for MSG_WAITALL. It copyout the received data to userspace by received chunks. I do not understand your note about effectiveness there. >=20 > KB> Also, what is the MT_CONTROL chunk about ? >=20 > When I removed the condition to skip blocking in the first part I started= to > observe panic on KASSERT(m->m_type =3D=3D MT_DATA) for the following scen= ario > (produced by HAST): >=20 > sender: >=20 > send(4 bytes); /* send protocol name */ > sendmsg(); /* send descriptor (normal data is empty, descriptor in co= ntrol data) */ >=20 > receiver: >=20 > recv(127 bytes, MSG_WAITALL); /* recive protocol name */ > recvmsg(); /* recive descriptor */ >=20 > Although the recv() has MSG_WAITALL, it exits after receiving 4 bytes bec= ause > the next received data is of different (MT_CONTROL) type. An it panicked = when > got control data. >=20 > It is unclear for me why it is not expected to have MT_CONTROL data in th= at > part. We do have processing of MT_CONTROL above (in the second part) in t= he > code but I still a have feeling that it is possible to create some scenar= io to > break this assert without my patch too, but I have failed so far. And thi= s is > my second concern about my patch, big enough, because for now I am not su= re > that this is correct. Although I have not observed issues with it so far.= .. I have no idea about this part. >=20 > Also, I am not sure if there is sense to bother with soreceive_generic() = at > all. May be it is more perspective to spend time on "maturing" > soreceive_stream(). As I see it is going to be a replacement for > soreceive_generic() for stream sockets. >=20 > --=20 > Mikolaj Golub --FM5zcXyvfv2Qtj+b Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk39xOMACgkQC3+MBN1Mb4iVbQCg5gbVdCW/Z4WjHOJbSbX+f0so OiIAnRszcR5KuqTtAUilOouMCCtSTsd/ =y8y3 -----END PGP SIGNATURE----- --FM5zcXyvfv2Qtj+b--