lib/tdb: fix OpenBSD incoherent mmap.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 22 Mar 2012 00:17:26 +0000 (10:47 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 22 Mar 2012 00:57:37 +0000 (01:57 +0100)
commitfde694274e1e5a11d1473695e7ec7a97f95d39e4
treeeafd3e0a305aaf4f537fa359ae6f812d046bff9c
parent584b996a1a27870dad30eb422d375bb08b57c64c
lib/tdb: fix OpenBSD incoherent mmap.

This comment appears in two places in the code (commit
4c6a8273c6dd3e2aeda5a63c4a62aa55bc133099 from 2001):

/*
 * We must ensure the file is unmapped before doing this
 * to ensure consistency with systems like OpenBSD where
 * writes and mmaps are not consistent.
 */

But this doesn't help, because if one process is using mmap and another
using pwrite, we get incoherent results.  As demonstrated by OpenBSD's
failure on the tdb unit tests.

Rather than disable mmap on OpenBSD, we test for this issue and force mmap
to be enabled.  This means that we will fail on very large TDBs on 32-bit
systems, but it's better than the horrendous performance penalty on every
OpenBSD system.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/tdb/common/io.c
lib/tdb/common/open.c
lib/tdb/common/tdb_private.h
lib/tdb/test/run-3G-file.c