From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 8 03:35:39 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B987616A4CE for ; Fri, 8 Oct 2004 03:35:39 +0000 (GMT) Received: from harmony.village.org (rover.village.org [168.103.84.182]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1014A43D2F for ; Fri, 8 Oct 2004 03:35:39 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (harmony.village.org [10.0.0.6]) by harmony.village.org (8.13.1/8.13.1) with ESMTP id i983YViA047196; Thu, 7 Oct 2004 21:34:31 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Thu, 07 Oct 2004 21:36:13 -0600 (MDT) Message-Id: <20041007.213613.34762646.imp@bsdimp.com> To: marc@msys.ch From: "M. Warner Losh" In-Reply-To: References: <20041006144800.GB87201@dan.emsphone.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-hackers@freebsd.org cc: dnelson@allantgroup.com Subject: Re: syslog() reentrant when compiling with -pthread? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2004 03:35:39 -0000 In message: Marc Balmer writes: : Am 06.10.2004 um 16:48 schrieb Dan Nelson: : : > The only unsafe part is openlog(), so set that up before you start any : > threads and you'll be okay. Once the log fd is opened, the syslog() : > call looks to be thread-safe. Everything in there is done with local : > variables and atomic writes. : : At least on OpenBSD I can use "%m" in the syslog() format string. This : results in a call to strerror(), which is not thread safe, AFAIK. This : probably is true for FreeBSD as well, so we have the following three : conditions for thread safe syslog(): : : 1) openlog() must be called before any threads that use syslog() are : started. : 2) The first argument to openlog() must not be NULL. : 3) The "%m" Format String must not be used in syslog() calls. : : Any comments? strerror is thread safe, unless your errno is outside of the valid range. Warner