Skip to content

Commit c7f0d22

Browse files
committed
Arrange lmdb logic: htdbm -x wasn't working because the database was MDB_RDONLY.
Additionally add comments in the code. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1928729 13f79535-47bb-0310-9956-ffa450edef68
1 parent 700166a commit c7f0d22

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

dbm/apr_dbm_lmdb.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ typedef struct {
4242

4343
#define APR_DBM_LMDBMODE_RO MDB_RDONLY
4444
#define APR_DBM_LMDBMODE_RWCREATE MDB_CREATE
45-
#define APR_DBM_LMDBMODE_RW (MDB_RDONLY + MDB_CREATE + 1)
46-
#define APR_DBM_LMDBMODE_RWTRUNC (APR_DBM_LMDBMODE_RW + 1)
4745

4846
/* --------------------------------------------------------------------------
4947
**
@@ -99,13 +97,13 @@ static apr_status_t vt_lmdb_open(apr_dbm_t **pdb, const char *pathname,
9997
dbmode = APR_DBM_LMDBMODE_RO;
10098
break;
10199
case APR_DBM_READWRITE:
102-
dbmode = APR_DBM_LMDBMODE_RW;
100+
dbmode = 0;
103101
break;
104102
case APR_DBM_RWCREATE:
105103
dbi_open_flags = APR_DBM_LMDBMODE_RWCREATE;
106104
break;
107105
case APR_DBM_RWTRUNC:
108-
truncate = APR_DBM_LMDBMODE_RWTRUNC;
106+
truncate = 1;
109107
break;
110108
default:
111109
return APR_EINVAL;
@@ -125,14 +123,17 @@ static apr_status_t vt_lmdb_open(apr_dbm_t **pdb, const char *pathname,
125123
}
126124

127125
if (dberr == 0) {
126+
/* we pass MDB_RDONLY and the default */
128127
dberr = mdb_env_open(file.env, pathname, dbmode | DEFAULT_ENV_FLAGS, apr_posix_perms2mode(perm));
129128
}
130129

131130
if (dberr == 0) {
131+
/* we pass MDB_RDONLY */
132132
dberr = mdb_txn_begin(file.env, NULL, dbmode, &file.txn);
133133
}
134134

135135
if (dberr == 0) {
136+
/* we pass the DB_CREATE */
136137
dberr = mdb_dbi_open(file.txn, NULL, dbi_open_flags, &file.dbi);
137138

138139
/* if mode == APR_DBM_RWTRUNC, drop database */

0 commit comments

Comments
 (0)