git: libc - Protect dbm_*() API with a mutex
dillon at crater.dragonflybsd.org
Wed Apr 20 12:07:45 PDT 2022
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Wed Apr 20 11:57:40 2022 -0700
libc - Protect dbm_*() API with a mutex
* The dbm_*() API is not thread-safe. Generally speaking, libc is
expected to be thread-safe these days.
* Protect the dbm_*() API with a mutex in the DB (aka DBM) structure.
We use available pthread_mutex_*() stubs for the locking, so they
are basically NOPs for applications not linked against pthreads.
* Also protect dbm_delete() and dbm_store() with our new sigblockall() /
sigunblockall() mechanism to prevent corruption due to ^C and
other regular signals. This mechanism implements a simple kernel/user
shared-memory counter and flag, and imposes no additional system calls
in DBM's critical paths.
Summary of changes:
include/db.h | 3 +++
lib/libc/db/hash/ndbm.c | 44 +++++++++++++++++++++++++++++++++++++++++---
2 files changed, 44 insertions(+), 3 deletions(-)
DragonFly BSD source repository
More information about the Commits