db: before add locks on db.c