Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Apr 2001 16:58:56 -0700 (PDT)
From:      Matt Dillon <dillon@earth.backplane.com>
To:        Terry Lambert <tlambert@primenet.com>
Cc:        current@FreeBSD.ORG
Subject:   Re: More on Bad Bug
Message-ID:  <200104172358.f3HNwua11870@earth.backplane.com>
References:   <200104172328.QAA01367@usr09.primenet.com>

next in thread | previous in thread | raw e-mail | index | archive | help

:There seems to be some bad code in soo_close(), which looks like:
:
:	int
:	soo_close(fp, p)
:		struct file *fp;
:		struct proc *p;   
:	{
:		int error = 0;
:
:		fp->f_ops = &badfileops;
:		if (fp->f_data)
:			error = soclose((struct socket *)fp->f_data);
:		fp->f_data = 0; 
:		return (error);
:	}
:
:It seems to me this should be?
:
:	int
:	soo_close(fp, p)
:		struct file *fp;
:		struct proc *p;   
:	{
:		int error = 0;
:
:		if (fp->f_data)
:			error = soclose((struct socket *)fp->f_data);
:		if (!error) {
:			fp->f_data = 0; 
:			fp->f_ops = &badfileops;
:		}
:		return (error);
:	}
:...
:But it's not clear that this is correct for the socket code.

    I think this is ok.  soclose() is passed a socket structure which
    has no concept of the original struct file that held it.

:Credentials are actually used _AMAZINGLY_ much; it seems that they
:are a good candidate for some optimization to throw away references
:that aren't really necessary (for example, it seems to me that a
:socket can not exist without an fdp referencing it, and the fdp has
:a reference count on the cred which the socket inherits from the fdp,
:so the fdp's reference protects the sockets reference, and so the
:socket's reference doesn't really need to be reference counted).

    There should be a reference count for each reference.  The credential
    is stored in the socket structure so it is the responsibility of the 
    socket code to gain another reference to it when it makes the assignment.

    I wouldn't worry about trying to optimize ref count cases... you are
    talking about nanoseconds there.

:In any case, I'm leaving in the panic patch I sent earlier, and am
:now rebuilding with my ucred reference count moved past the area

    I think the panic patch is an excellent idea and should be comitted
    and (after we unfreeze) MFC'd.  Moving the ref count to catch
    double-frees is a good idea as well.

:I guess no one else is interested in this bug hunt, or no one else
:is using 30,000 sockets on any of their machines?
:
:					Terry Lambert
:					terry@lambert.org

    I'm still interested!

						-Matt


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200104172358.f3HNwua11870>