From owner-freebsd-bugs@FreeBSD.ORG Sun Apr 6 19:40:02 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D2772E45 for ; Sun, 6 Apr 2014 19:40:02 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BF66E278 for ; Sun, 6 Apr 2014 19:40:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s36Je23D006093 for ; Sun, 6 Apr 2014 19:40:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s36Je2kP006089; Sun, 6 Apr 2014 19:40:02 GMT (envelope-from gnats) Date: Sun, 6 Apr 2014 19:40:02 GMT Message-Id: <201404061940.s36Je2kP006089@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Jilles Tjoelker Subject: Re: bin/109478: [libc] [patch] adopt reentrant syslog functions from OpenBSD X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Apr 2014 19:40:02 -0000 The following reply was made to PR bin/109478; it has been noted by GNATS. From: Jilles Tjoelker To: bug-followup@FreeBSD.org, skreuzer@f2o.org Cc: Subject: Re: bin/109478: [libc] [patch] adopt reentrant syslog functions from OpenBSD Date: Sun, 6 Apr 2014 21:32:34 +0200 In FreeBSD PR bin/109478, you wrote: > The patch essentially takes OpenBSD's reentrant syslog functions > (openlog_r, closelog_r, syslog_r and vsyslog_r) and makes them > available in FreeBSD. Hopefully this will make building of packages > such as spamd under FreeBSD easier since the source shouldn't require > modifications. There may be some point in syslog functions without global data, but I think OpenBSD's API exposes way too much information about the implementation and is therefore bad for ABI stability and encapsulation. Specifically, this kind of struct seems bad (in the header file): > +/* Used by reentrant functions */ > + > +struct syslog_data { > + int log_file; > + int connected; > + int opened; > + int log_stat; > + const char *log_tag; > + int log_fac; > + int log_mask; > +}; > + > +#define SYSLOG_DATA_INIT {-1, 0, 0, 0, (const char *)0, LOG_USER, 0xff} A better way would be for openlog_r() to allocate something and closelog_r() to free it again. I don't really like the word "reentrant"; I prefer terms like "thread-safe" and "async-signal safe" with clear definitions. It seems that async-signal safe is meant here, since our syslog implementation is thread-safe by locking. -- Jilles Tjoelker