From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 23 08:40:51 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6BED016A4CE for ; Fri, 23 Jan 2004 08:40:51 -0800 (PST) Received: from phantom.cris.net (phantom.cris.net [212.110.130.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1854043D3F for ; Fri, 23 Jan 2004 08:40:45 -0800 (PST) (envelope-from ru@FreeBSD.org.ua) Received: from phantom.cris.net (ru@localhost [127.0.0.1]) by phantom.cris.net (8.12.10/8.12.10) with ESMTP id i0NGfPem039137; Fri, 23 Jan 2004 18:41:25 +0200 (EET) (envelope-from ru@FreeBSD.org.ua) Received: (from ru@localhost) by phantom.cris.net (8.12.10/8.12.10/Submit) id i0NGfP4o039132; Fri, 23 Jan 2004 18:41:25 +0200 (EET) (envelope-from ru) Date: Fri, 23 Jan 2004 18:41:25 +0200 From: Ruslan Ermilov To: Stuart Pook Message-ID: <20040123164125.GF38510@FreeBSD.org.ua> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wtjvnLv0o8UUzur2" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.5.1i cc: freebsd-hackers@freebsd.org Subject: Re: send(2) does not block, send(2) man page wrong? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jan 2004 16:40:51 -0000 --wtjvnLv0o8UUzur2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 23, 2004 at 04:25:07PM +0100, Stuart Pook wrote: > The documentation for send(2) says >=20 > If no messages space is available at the socket to hold the message to be > transmitted, then send() normally blocks, unless the socket has been > placed in non-blocking I/O mode. The select(2) call may be used to > determine when it is possible to send more data. > =09 > I cannot get send (or sendto which is what really interests me) > to block on FreeBSD 4.9. When I send as fast as I can to a socket, > send rapidly fails with ENOBUFS. I am not surprised that the kernel is > running out of mbufs but I am surprised that send does not block until > more become available. >=20 > Select does not block either. It always says that I can write to the > socket and then send fails with ENOBUFS. >=20 > The udp_output function in /sys/netinet/udp_usrreq.c, seems clear: >=20 > /* > * Calculate data length and get a mbuf > * for UDP and IP headers. > */ > M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT); > if (m =3D=3D 0) { > error =3D ENOBUFS; > if (addr) > splx(s); > goto release; > } > =20 > There is no sign of send blocking waiting for a mbuf or of it returning > EAGAIN if the socket is non-blocking. >=20 > Is the documentation for send(2) wrong or is there some way to make > send and sendto block? >=20 > I have used setsockopt(s, SOL_SOCKET, SO_SNDBUF) to reduce the size > of the output queue for the socket but send still returns ENOBUFS and > never blocks or returns EAGAIN. >=20 UDP sockets don't use send buffer (like TCP does) for storing data, only receive buffer, so SO_SNDBUF only affects the maximum size of one write operation. Cheers, --=20 Ruslan Ermilov FreeBSD committer ru@FreeBSD.org --wtjvnLv0o8UUzur2 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAEU61Ukv4P6juNwoRApb9AKCJbBztuUUw/Jydpvop0Q4VOf/aBQCfXYBn K72YBoonnH9mD+5KcumQYt4= =RxVa -----END PGP SIGNATURE----- --wtjvnLv0o8UUzur2--