From owner-freebsd-threads@FreeBSD.ORG Thu Dec 29 06:30:16 2005 Return-Path: X-Original-To: freebsd-threads@hub.freebsd.org Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A5E1116A423 for ; Thu, 29 Dec 2005 06:30:16 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A1AC443D5C for ; Thu, 29 Dec 2005 06:30:15 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id jBT6UFbG073625 for ; Thu, 29 Dec 2005 06:30:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id jBT6UFUp073622; Thu, 29 Dec 2005 06:30:15 GMT (envelope-from gnats) Date: Thu, 29 Dec 2005 06:30:15 GMT Message-Id: <200512290630.jBT6UFUp073622@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: David Xu Cc: Subject: Re: threads/79887: [patch] freopen() isn't thread-safe X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: David Xu List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2005 06:30:16 -0000 The following reply was made to PR threads/79887; it has been noted by GNATS. From: David Xu To: Dmitrij Tejblum Cc: bug-followup@freebsd.org Subject: Re: threads/79887: [patch] freopen() isn't thread-safe Date: Thu, 29 Dec 2005 14:23:39 +0800 Dmitrij Tejblum wrote: > > Well, this is C, not C++, so there cannot be strict difference between > allowed and disallowed. But the _close field is not required by any > standarts (funopen() too) and is not documented by manpages (I checked > manpages with grep). And there does exist documented interface for > setting _close: funopen(). Thus _close is internal. > > > Then why use the following code to close a file descriptor, if (isopen) (void) (*fp->_close)(fp->_cookie); Why don't use _close(fp->_file)? this should be faster. This implies that someone can replace fp->_close with another function pointer,so that function must be called unconditionally. I think the libc should have a document to clarify this problem. Also should we move the PR to freebsd-standard@ list ?