From owner-freebsd-net Tue Dec 12 7:50: 3 2000 From owner-freebsd-net@FreeBSD.ORG Tue Dec 12 07:49:57 2000 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mail.interware.hu (mail.interware.hu [195.70.32.130]) by hub.freebsd.org (Postfix) with ESMTP id B706537B400; Tue, 12 Dec 2000 07:49:56 -0800 (PST) Received: from luanda-36.budapest.interware.hu ([195.70.51.36] helo=elischer.org) by mail.interware.hu with esmtp (Exim 3.16 #1 (Debian)) id 145rgX-0004OU-00; Tue, 12 Dec 2000 16:49:45 +0100 Sender: julian@FreeBSD.ORG Message-ID: <3A36215A.712AE09A@elischer.org> Date: Tue, 12 Dec 2000 05:00:10 -0800 From: Julian Elischer X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en, hu MIME-Version: 1.0 To: Alfred Perlstein Cc: net@freebsd.org, bmilekic@freebsd.org Subject: Re: need mbuf generic free() hook References: <20001212042447.E16205@fw.wintelcom.net> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Alfred Perlstein wrote: > > Ok, so I'm trying to rid FreeBSD of the unp_gc() junk in uipc_usrreq.c > I just realized why I'm leaking file descriptors: > > Only mbufs with external storage can have a 'free' function, the > problem is that for the most part when passing a single fd I'm only > using a single mbuf to pass my data around, my ext_free routine is > probably never called, and on top of that I'm probably corrupting > my mbuf by using it when I shouldn't be. > > This is terrible, what should be a simple free() hook is now my > worst nightmare. A couple of options come to mind: > > a) always have a free hook, the extra if (m->m_freehook != NULL) > check can't be that expensive. > b) a macro to make an mbuf into an mbuf cluster that points to itself, > it should check to see if it has enough room to shuffle the data > and return an error if it can't accomidate both the data and the > expanded mbug header. > > I like 'a' but would be willing to deal with 'b' as we've never > had a need for this, although that would mean copying about the > size of an mbuf in the worst case when a subsystem needs this > facility. The external object in the mbuf can be virtual. You can Say it is external and point the pointers to a static place and set the mbuf to b ereadonly and have an m_len of 0 Then your free routine woild be called, but you would not need to alocate a cluster for it. > > Suggestions? Comments? > > -- > -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] > "I have the heart of a child; I keep it in a jar on my desk." > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-net" in the body of the message -- __--_|\ Julian Elischer / \ julian@elischer.org ( OZ ) World tour 2000 ---> X_.---._/ presently in: Budapest v To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message