Move LMDB common definitions in a dedicated header

As several places uses custom LMDB macros, this centralize those
definitions inside a dedicated `lib/isc/include/isc/lmdb.h` header
file, so future uses cases not DNS-centrics could fit into there as
well.

MDB_CREATE is removed as well because:

- it was useless (it's needed only for named DB, which is not the case
  for all use case so far)

- it was used in `mdb_env_open` which is not expecting this flag: it
  should be passed (if needed) to `mdb_dbi_open`. It was likely
  ignored so far.
This commit is contained in:
Colin Vidal
2025-01-14 12:14:27 +01:00
parent 5b1996eea0
commit c225990b8e
7 changed files with 34 additions and 17 deletions
+1 -2
View File
@@ -45,6 +45,7 @@
#include <isc/httpd.h>
#include <isc/job.h>
#include <isc/lex.h>
#include <isc/lmdb.h>
#include <isc/loop.h>
#include <isc/meminfo.h>
#include <isc/netmgr.h>
@@ -140,8 +141,6 @@
#include <named/smf_globals.h>
#endif /* ifdef HAVE_LIBSCF */
#include <lmdb.h>
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)-1)
#endif /* ifndef SIZE_MAX */
+2 -1
View File
@@ -11,10 +11,11 @@
* information regarding copyright ownership.
*/
#include <lmdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <isc/lmdb.h>
#include <dns/view.h>
int
-11
View File
@@ -246,17 +246,6 @@ struct dns_view {
#define DNS_VIEWATTR_ADBSHUTDOWN 0x02
#define DNS_VIEWATTR_REQSHUTDOWN 0x04
#define DNS_LMDB_COMMON_FLAGS (MDB_CREATE | MDB_NOSUBDIR | MDB_NOLOCK)
#ifndef __OpenBSD__
#define DNS_LMDB_FLAGS (DNS_LMDB_COMMON_FLAGS)
#else /* __OpenBSD__ */
/*
* OpenBSD does not have a unified buffer cache, which requires both reads and
* writes to be performed using mmap().
*/
#define DNS_LMDB_FLAGS (DNS_LMDB_COMMON_FLAGS | MDB_WRITEMAP)
#endif /* __OpenBSD__ */
isc_result_t
dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_dispatchmgr_t *dispmgr, dns_rdataclass_t rdclass,
+1 -1
View File
@@ -15,7 +15,6 @@
#include <inttypes.h>
#include <limits.h>
#include <lmdb.h>
#include <stdbool.h>
#include <isc/atomic.h>
@@ -23,6 +22,7 @@
#include <isc/file.h>
#include <isc/hash.h>
#include <isc/lex.h>
#include <isc/lmdb.h>
#include <isc/md.h>
#include <isc/result.h>
#include <isc/stats.h>
+1
View File
@@ -44,6 +44,7 @@ libisc_la_HEADERS = \
include/isc/job.h \
include/isc/lex.h \
include/isc/list.h \
include/isc/lmdb.h \
include/isc/log.h \
include/isc/loop.h \
include/isc/magic.h \
+2 -2
View File
@@ -11,17 +11,17 @@
* information regarding copyright ownership.
*/
#include <lmdb.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <isc/cfgmgr.h>
#include <isc/list.h>
#include <isc/lmdb.h>
#include <isc/mem.h>
#include <isc/random.h>
#include <isc/thread.h>
#include <isc/util.h>
#include <isc/cfgmgr.h>
/*
* See MDB_MAXKEYSIZE documentation, but not accessible as defined in
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#pragma once
#include <lmdb.h>
#define DNS_LMDB_COMMON_FLAGS (MDB_NOSUBDIR | MDB_NOLOCK)
#ifndef __OpenBSD__
#define DNS_LMDB_FLAGS (DNS_LMDB_COMMON_FLAGS)
#else /* __OpenBSD__ */
/*
* OpenBSD does not have a unified buffer cache, which requires both reads and
* writes to be performed using mmap().
*/
#define DNS_LMDB_FLAGS (DNS_LMDB_COMMON_FLAGS | MDB_WRITEMAP)
#endif /* __OpenBSD__ */