Date: Fri, 23 Jan 2004 18:41:25 +0200 From: Ruslan Ermilov <ru@freebsd.org> To: Stuart Pook <Stuart.Pook@infres.enst.fr> Cc: freebsd-hackers@freebsd.org Subject: Re: send(2) does not block, send(2) man page wrong? Message-ID: <20040123164125.GF38510@FreeBSD.org.ua> In-Reply-To: <E1Ak3BD-0006pn-00@roo> References: <E1Ak3BD-0006pn-00@roo>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040123164125.GF38510>