LMDB_DB_SIZE can be overriden by $OTR_LMDBSIZE

closes #348
This commit is contained in:
Jan-Piet Mens
2022-05-23 18:26:03 +02:00
parent 47b2fe6351
commit 1f10adfa64
2 changed files with 11 additions and 1 deletions
+1
View File
@@ -294,6 +294,7 @@ The following configuration settings may be applied (a `Y` in column `$` means a
| `OTR_CAPATH` | Y | | Directory of c_rehashed PEM certificates
| `OTR_CERTFILE` | Y | | Path to PEM-encoded client certificate for MQTT
| `OTR_KEYFILE` | Y | | Path to PEM-encoded client key for MQTT
| `OTR_LMDBSIZE` | Y | `104857600000` | size of the LMDB database. If less than 10485760 (10 MB) it will be set to 10485760.
Note that options passed to `ot-recorder` override both configuration file settings and environment variables.
+10 -1
View File
@@ -32,10 +32,19 @@
struct gcache *gcache_open(char *path, char *dbname, int rdonly)
{
size_t lmdb_size = LMDB_DB_SIZE;
MDB_txn *txn = NULL;
int rc;
unsigned int flags = 0, dbiflags = 0, perms = 0664;
struct gcache *gc;
char *p;
if ((p = getenv("OTR_LMDBSIZE")) != NULL) {
lmdb_size = atol(p);
if (lmdb_size < 10485760) { // 10 MB
lmdb_size = 10485760;
}
}
if (!is_directory(path)) {
olog(LOG_ERR, "gcache_open: %s is not a directory", path);
@@ -62,7 +71,7 @@ struct gcache *gcache_open(char *path, char *dbname, int rdonly)
return (NULL);
}
mdb_env_set_mapsize(gc->env, LMDB_DB_SIZE);
mdb_env_set_mapsize(gc->env, lmdb_size);
rc = mdb_env_set_maxdbs(gc->env, 10);
if (rc != 0) {