From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 6 14:48:06 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 2C0F016A4CE for ; Wed, 6 Oct 2004 14:48:06 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id D337543D5A for ; Wed, 6 Oct 2004 14:48:05 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.11/8.12.11) id i96Em1oY057109; Wed, 6 Oct 2004 09:48:01 -0500 (CDT) (envelope-from dan) Date: Wed, 6 Oct 2004 09:48:00 -0500 From: Dan Nelson To: Marc Balmer Message-ID: <20041006144800.GB87201@dan.emsphone.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 5.3-BETA7 X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: freebsd-hackers@freebsd.org 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: Wed, 06 Oct 2004 14:48:06 -0000 In the last episode (Oct 06), Marc Balmer said: > I am a long time Unix developer but new with FreeBSD. I worked the > last years mostly with OpenBSD. First I am overwhelmed by the number > of mailing lists you guys provide. Second I am not sure if I picked > the right one ;-) So please direct me to the right place if this list > is only for discussion of FreeBSD system development... > > My question regarding thread-safeness of syslog(): On OpenBSD I used > syslog_r() to do thread safe logging (the software in question is a > sendmail milter, which runs multithreaded). FreeBSD does not have > these functions, but the cc man page states that compiling with > "-pthread" links in the thread safe libc_r library instead of libc. > As syslog() seems to part of libc on FreeBSD, is it safe to assume > that syslog() is indeed thread safe on FreeBSD when compiling with > the -pthread switch? 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. -- Dan Nelson dnelson@allantgroup.com