From owner-freebsd-arch Sun Dec 3 12: 6:25 2000 From owner-freebsd-arch@FreeBSD.ORG Sun Dec 3 12:06:23 2000 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from smtp05.primenet.com (smtp05.primenet.com [206.165.6.135]) by hub.freebsd.org (Postfix) with ESMTP id C2BAA37B400; Sun, 3 Dec 2000 12:06:22 -0800 (PST) Received: (from daemon@localhost) by smtp05.primenet.com (8.9.3/8.9.3) id NAA07008; Sun, 3 Dec 2000 13:02:59 -0700 (MST) Received: from usr05.primenet.com(206.165.6.205) via SMTP by smtp05.primenet.com, id smtpdAAA5oaWQn; Sun Dec 3 13:02:58 2000 Received: (from tlambert@localhost) by usr05.primenet.com (8.8.5/8.8.5) id NAA00585; Sun, 3 Dec 2000 13:06:02 -0700 (MST) From: Terry Lambert Message-Id: <200012032006.NAA00585@usr05.primenet.com> Subject: Re: zero copy code review To: dg@root.com Date: Sun, 3 Dec 2000 20:06:01 +0000 (GMT) Cc: gallatin@cs.duke.edu (Andrew Gallatin), bmilekic@technokratis.com (Bosko Milekic), ken@kdm.org (Kenneth D. Merry), arch@FreeBSD.ORG, alfred@FreeBSD.ORG In-Reply-To: <200012012326.PAA14154@implode.root.com> from "David Greenman" at Dec 01, 2000 03:26:19 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: tlambert@usr05.primenet.com Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > > In your code, you do deal with the possibility of the MGETHDR > > > returning NULL (you check for it) and you set ENOBUFS in that case and > > > jump to the "errorpath" label. But, before using MGETHDR, you allocate an > > > sf_buf (in sf) and it just so happens that the code beyond "errorpath" > > > does not take care of freeing the sf_buf you allocated before even > > > trying to allocate the mbuf. > > > >I see your point. This was copied, (bug for bug ;-), from sendfile itself. > >Look at line 1700 or so of kern/uipc_syscalls.c.. This bug should > >probaby be fixed there too.. > > Oops. The original assumption (and code that I wrote) was that M_WAIT > _cannot_ return a NULL pointer. This was changed in FreeBSD recently, and > as you mentioned, the code added in rev 1.65 that now checks for it in > sendfile doesn't do complete cleanup in this case. It definately should > be fixed so that the sf_buf is freed as well. There's a real easy fix for this: m_get_not_broken( flag, type) int flag, type; { struct mbuf *m; do { m = m_get( flag, type); } while( flag == M_WAIT && m == NULL); return( m); } I think the idea that the M_WAIT flag should be broken so that it can be safely used in interrupt mode is dumb. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message