Bug 109478 - [libc] [patch] adopt reentrant syslog functions from OpenBSD
Summary: [libc] [patch] adopt reentrant syslog functions from OpenBSD
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 6.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-23 22:10 UTC by Steven Kreuzer
Modified: 2017-12-31 22:27 UTC (History)
0 users

See Also:


Attachments
file.diff (16.05 KB, patch)
2007-02-23 22:10 UTC, Steven Kreuzer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Kreuzer 2007-02-23 22:10:05 UTC
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.

Fix: Patch attached with submission follows:
Comment 1 Jilles Tjoelker freebsd_committer 2014-04-06 20:32:34 UTC
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
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:49 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped