mirror of
https://github.com/vdukhovni/postfix
synced 2025-08-30 21:55:20 +00:00
postfix-3.3-20170613
This commit is contained in:
committed by
Viktor Dukhovni
parent
0de740ad65
commit
e0d44feb73
@@ -881,7 +881,6 @@ void mail_params_init()
|
||||
check_sgid_group();
|
||||
check_overlap();
|
||||
dict_db_cache_size = var_db_read_buf;
|
||||
dict_db_home = mystrdup(var_config_dir);
|
||||
dict_lmdb_map_size = var_lmdb_map_size;
|
||||
inet_windowsize = var_inet_windowsize;
|
||||
|
||||
|
@@ -7,7 +7,6 @@
|
||||
/* #include <dict_db.h>
|
||||
/*
|
||||
/* extern int dict_db_cache_size;
|
||||
/* extern char *dict_db_home;
|
||||
/*
|
||||
/* DEFINE_DICT_DB_CACHE_SIZE;
|
||||
/*
|
||||
@@ -34,9 +33,6 @@
|
||||
/* must therefore be defined in the calling program by invoking
|
||||
/* the DEFINE_DICT_DB_CACHE_SIZE macro at the global level.
|
||||
/*
|
||||
/* dict_db_home specifies the default location of the DB_CONFIG
|
||||
/* file with configuration overrides.
|
||||
/*
|
||||
/* Arguments:
|
||||
/* .IP path
|
||||
/* The database pathname, not including the ".db" suffix.
|
||||
@@ -572,6 +568,44 @@ static void dict_db_close(DICT *dict)
|
||||
dict_free(dict);
|
||||
}
|
||||
|
||||
#if DB_VERSION_MAJOR > 2
|
||||
|
||||
/* dict_db_new_env - workaround for undocumented ./DB_CONFIG read */
|
||||
|
||||
static DB_ENV *dict_db_new_env(const char *db_path)
|
||||
{
|
||||
VSTRING *db_home_buf;
|
||||
DB_ENV *dbenv;
|
||||
u_int32_t cache_size_gbytes;
|
||||
u_int32_t cache_size_bytes;
|
||||
int ncache;
|
||||
|
||||
if ((errno = db_env_create(&dbenv, 0)) != 0)
|
||||
msg_fatal("create DB environment: %m");
|
||||
#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 7)
|
||||
if ((errno = dbenv->get_cachesize(dbenv, &cache_size_gbytes,
|
||||
&cache_size_bytes, &ncache)) != 0)
|
||||
msg_fatal("get DB cache size: %m");
|
||||
if (cache_size_gbytes == 0 && cache_size_bytes < dict_db_cache_size) {
|
||||
if ((errno = dbenv->set_cache_max(dbenv, cache_size_gbytes,
|
||||
dict_db_cache_size)) != 0)
|
||||
msg_fatal("set DB max cache size %d: %m", dict_db_cache_size);
|
||||
if ((errno = dbenv->set_cachesize(dbenv, cache_size_gbytes,
|
||||
dict_db_cache_size, ncache)) != 0)
|
||||
msg_fatal("set DB cache size %d: %m", dict_db_cache_size);
|
||||
}
|
||||
#endif
|
||||
/* XXX db_home is also the default directory for the .db file. */
|
||||
db_home_buf = vstring_alloc(100);
|
||||
if ((errno = dbenv->open(dbenv, sane_dirname(db_home_buf, db_path),
|
||||
DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0)) != 0)
|
||||
msg_fatal("open DB environment: %m");
|
||||
vstring_free(db_home_buf);
|
||||
return (dbenv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* dict_db_open - open data base */
|
||||
|
||||
static DICT *dict_db_open(const char *class, const char *path, int open_flags,
|
||||
@@ -590,9 +624,6 @@ static DICT *dict_db_open(const char *class, const char *path, int open_flags,
|
||||
#endif
|
||||
#if DB_VERSION_MAJOR > 2
|
||||
DB_ENV *dbenv;
|
||||
u_int32_t cache_size_gbytes;
|
||||
u_int32_t cache_size_bytes;
|
||||
int ncache;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -698,29 +729,7 @@ static DICT *dict_db_open(const char *class, const char *path, int open_flags,
|
||||
db_flags |= DB_CREATE;
|
||||
if (open_flags & O_TRUNC)
|
||||
db_flags |= DB_TRUNCATE;
|
||||
/* Begin fix 20170611 workaround for undocumented ./DB_CONFIG read. */
|
||||
if ((errno = db_env_create(&dbenv, 0)) != 0)
|
||||
msg_fatal("create DB environment: %m");
|
||||
#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 7)
|
||||
/* Begin fix 20170612 workaround for invisible cache size limit. */
|
||||
if ((errno = dbenv->get_cachesize(dbenv, &cache_size_gbytes,
|
||||
&cache_size_bytes, &ncache)) != 0)
|
||||
msg_fatal("get DB cache size: %m");
|
||||
if (cache_size_gbytes == 0 && cache_size_bytes < dict_db_cache_size) {
|
||||
if ((errno = dbenv->set_cache_max(dbenv, cache_size_gbytes,
|
||||
dict_db_cache_size)) != 0)
|
||||
msg_fatal("set DB max cache size %d: %m", dict_db_cache_size);
|
||||
if ((errno = dbenv->set_cachesize(dbenv, cache_size_gbytes,
|
||||
dict_db_cache_size, ncache)) != 0)
|
||||
msg_fatal("set DB cache size %d: %m", dict_db_cache_size);
|
||||
}
|
||||
/* End fix 20170612 workaround for invisible cache size limit. */
|
||||
#endif
|
||||
if ((errno = dbenv->open(dbenv, dict_db_home,
|
||||
DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0)) != 0)
|
||||
msg_fatal("open DB environment: %m");
|
||||
/* End fix 20170611 workaround for undocumented ./DB_CONFIG read. */
|
||||
if ((errno = db_create(&db, dbenv, 0)) != 0)
|
||||
if ((errno = db_create(&db, dbenv = dict_db_new_env(db_path), 0)) != 0)
|
||||
msg_fatal("create DB database: %m");
|
||||
if (db == 0)
|
||||
msg_panic("db_create null result");
|
||||
|
@@ -33,10 +33,8 @@ extern DICT *dict_btree_open(const char *, int, int);
|
||||
* set a larger memory pool for database (re)builds.
|
||||
*/
|
||||
extern int dict_db_cache_size;
|
||||
extern char *dict_db_home;
|
||||
|
||||
#define DEFINE_DICT_DB_CACHE_SIZE int dict_db_cache_size = (128 * 1024)
|
||||
#define DEFINE_DICT_DB_HOME char *dict_db_home = "/"
|
||||
|
||||
/* LICENSE
|
||||
/* .ad
|
||||
|
@@ -395,7 +395,6 @@ static DICT_MAPNAMES_EXTEND_FN dict_mapnames_extend_hook;
|
||||
*/
|
||||
DEFINE_DICT_LMDB_MAP_SIZE;
|
||||
DEFINE_DICT_DB_CACHE_SIZE;
|
||||
DEFINE_DICT_DB_HOME;
|
||||
|
||||
/* dict_open_init - one-off initialization */
|
||||
|
||||
|
Reference in New Issue
Block a user