]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10454 lmdb: can't rely on O_DSYNC on MacOS
authorHoward Chu <hyc@openldap.org>
Wed, 15 Apr 2026 18:39:36 +0000 (19:39 +0100)
committerHoward Chu <hyc@openldap.org>
Wed, 15 Apr 2026 18:47:58 +0000 (19:47 +0100)
So we must explicitly sync writes to the metapage.

libraries/liblmdb/mdb.c

index 6247f867ab8315f1eb47e2e23169ff26f301ce69..1c885e8dd6ac680fd28face20d7fb7a61e9c75bc 100644 (file)
@@ -4865,6 +4865,12 @@ mdb_env_write_meta(MDB_txn *txn)
                                rc = ErrCode();
                                goto fail;
                        }
+#if defined(__APPLE__)
+                       if (MDB_FDATASYNC(env->me_mfd)) {
+                               rc = ErrCode();
+                               goto fail;
+                       }
+#endif
                }
                goto done;
        }
@@ -4924,6 +4930,12 @@ fail:
                env->me_flags |= MDB_FATAL_ERROR;
                return rc;
        }
+#if defined(__APPLE__)
+       if (mfd == env->me_mfd && MDB_FDATASYNC(env->me_mfd)) {
+               rc = ErrCode();
+               return rc;
+       }
+#endif
        /* MIPS has cache coherency issues, this is a no-op everywhere else */
        CACHEFLUSH(env->me_map + off, len, DCACHE);
 done: