From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 23 09:09:36 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 97F0616A4CE for ; Fri, 23 Jan 2004 09:09:36 -0800 (PST) Received: from mailtoaster1.pipeline.ch (mailtoaster1.pipeline.ch [62.48.0.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id E9D3943D90 for ; Fri, 23 Jan 2004 09:09:21 -0800 (PST) (envelope-from andre@freebsd.org) Received: (qmail 34771 invoked from network); 23 Jan 2004 17:09:18 -0000 Received: from unknown (HELO freebsd.org) ([62.48.0.47]) (envelope-sender ) by mailtoaster1.pipeline.ch (qmail-ldap-1.03) with SMTP for ; 23 Jan 2004 17:09:18 -0000 Message-ID: <40115540.7070701@freebsd.org> Date: Fri, 23 Jan 2004 18:09:20 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stuart Pook References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 17:09:36 -0000 Stuart Pook wrote: >>send() for UDP should block if the socket is filled and the interface >>can't drain the data fast enough. > > It doesn't (at least I cannot make it block) This stuff is rather complex. A send() on a UDP socket processes right down to the if_output. If that fails because the ifqueue is full, the packet will be free()d right away. No luck with blocking and retrying. >>Good question. There is not feedback loop like in tcp, so handling this >>blocking and releasing would be a little bit harder to do for UDP. > > Send(2) indicates that it should do so. True. The only thing I can offer is that when one packet produces an ENOBUFS, the socket will block on the next one for a couple of milliseconds. Doing the full program requires significant changes to the current structure of the BSD network code. You could do the same in userland with a call to nanosleep(2) when you get a ENOBUFS. >>>I have written a test program, >>>http://www.infres.enst.fr/~pook/send/server.c, that shows that send does >>>not block on FreeBSD. It does with Linux and Solaris. >> >>Do you know what the behaviour of Net- and/or OpenBSD is? > > NetBSD is the same as FreeBSD. I have not tested OpenBSD. > MacOS X is similiar to FreeBSD in that send doesn't block, howver > the send does not give an error: the packet is just thrown away. Browsing through the code I see that none of the BSDs are able to block on an UDP send. -- Andre