Howard Chu wrote:
Wietse Venema wrote:
Howard Chu:
The first patch adds a lock handler to the dict interface. I needed this
first, because MDB is fully transactional and does its own locking/concurrency
management. In particular, it does MVCC so readers always run lockless; since
they're fully isolated there's no actual need for "shared locks."

I have added a lock function pointer to the dictionary data structure,
so that a specific dictionary can override it if needed.

This locking function is not exposed to applications: it is used
only by dict_open().  Applications rely on the dict_open()
"lock-on-open" feature for maps that aren't multi-writer safe.

A multi-writer safe table like MDB could override this function
with a NOOP (or it could leave the lock_fd member equal to -1 and
achieve the exact same result).

In the case of postmap/postalias which truncate databases, a global
lock is needed to prevent readers from looking at an incomplete
database.  This has nothing to do with the dict_open() "lock-on-open"
feature for tables that aren't multi-writer safe.

OK, this is an updated MDB patch, with a bit of documentation added as well.
Based on the postfix-2.10-20121007 source.

Of course I screwed up the update. Needs this addition:

diff --git a/src/global/mkmap_mdb.c b/src/global/mkmap_mdb.c
index d55c7a7..c22eecf 100644
--- a/src/global/mkmap_mdb.c
+++ b/src/global/mkmap_mdb.c
@@ -82,6 +82,8 @@ MKMAP *mkmap_mdb_open(const char *path)
      * Fill in the generic members.
      */
     mkmap->open = dict_mdb_open;
+    mkmap->after_open = 0;
+    mkmap->after_close = 0;

     /*
      * MDB uses MVCC so it needs no special lock management here.



--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/

Reply via email to