From owner-freebsd-current Tue Apr 17 16:59: 4 2001 Delivered-To: freebsd-current@freebsd.org Received: from earth.backplane.com (earth-nat-cw.backplane.com [208.161.114.67]) by hub.freebsd.org (Postfix) with ESMTP id B32C537B422 for ; Tue, 17 Apr 2001 16:58:58 -0700 (PDT) (envelope-from dillon@earth.backplane.com) Received: (from dillon@localhost) by earth.backplane.com (8.11.2/8.11.2) id f3HNwua11870; Tue, 17 Apr 2001 16:58:56 -0700 (PDT) (envelope-from dillon) Date: Tue, 17 Apr 2001 16:58:56 -0700 (PDT) From: Matt Dillon Message-Id: <200104172358.f3HNwua11870@earth.backplane.com> To: Terry Lambert Cc: current@FreeBSD.ORG Subject: Re: More on Bad Bug References: <200104172328.QAA01367@usr09.primenet.com> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :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