git: libc - Protect dbm_*() API with a mutex

Matthew Dillon dillon at crater.dragonflybsd.org
Wed Apr 20 12:07:45 PDT 2022


commit bd5862e7077df8ab5b388587b2c1418d753a7494
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(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/bd5862e7077df8ab5b388587b2c1418d753a7494


-- 
DragonFly BSD source repository



More information about the Commits mailing list