Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dbm/apr_dbm_lmdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ typedef struct {

#define APR_DBM_LMDBMODE_RO MDB_RDONLY
#define APR_DBM_LMDBMODE_RWCREATE MDB_CREATE
#define APR_DBM_LMDBMODE_RW (MDB_RDONLY + MDB_CREATE + 1)
#define APR_DBM_LMDBMODE_RWTRUNC (APR_DBM_LMDBMODE_RW + 1)

/* --------------------------------------------------------------------------
**
Expand Down Expand Up @@ -99,13 +97,13 @@ static apr_status_t vt_lmdb_open(apr_dbm_t **pdb, const char *pathname,
dbmode = APR_DBM_LMDBMODE_RO;
break;
case APR_DBM_READWRITE:
dbmode = APR_DBM_LMDBMODE_RW;
dbmode = 0;
break;
case APR_DBM_RWCREATE:
dbi_open_flags = APR_DBM_LMDBMODE_RWCREATE;
break;
case APR_DBM_RWTRUNC:
truncate = APR_DBM_LMDBMODE_RWTRUNC;
truncate = 1;
break;
default:
return APR_EINVAL;
Expand All @@ -125,14 +123,17 @@ static apr_status_t vt_lmdb_open(apr_dbm_t **pdb, const char *pathname,
}

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

if (dberr == 0) {
/* we pass MDB_RDONLY */
dberr = mdb_txn_begin(file.env, NULL, dbmode, &file.txn);
}

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

/* if mode == APR_DBM_RWTRUNC, drop database */
Expand Down
13 changes: 13 additions & 0 deletions test/testshm.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ static void test_named_remove(abts_case *tc, void *data)
}
ABTS_PTR_NOTNULL(tc, shm);

#ifdef WIN32
rv = apr_shm_destroy(shm);
#else
rv = apr_shm_remove(SHARED_FILENAME, p);
#endif

/* On platforms which acknowledge the removal of the shared resource,
* ensure another of the same name may be created after removal;
Expand All @@ -237,8 +241,10 @@ static void test_named_remove(abts_case *tc, void *data)
APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);
}

#ifndef WIN32
rv = apr_shm_destroy(shm);
APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);
#endif

/* Now ensure no named resource remains which we may attach to */
rv = apr_shm_attach(&shm, SHARED_FILENAME, p);
Expand All @@ -259,7 +265,12 @@ static void test_named_delete(abts_case *tc, void *data)
}
ABTS_PTR_NOTNULL(tc, shm);


#ifdef WIN32
rv = apr_shm_destroy(shm);
#else
rv = apr_shm_delete(shm);
#endif

/* On platforms which acknowledge the removal of the shared resource,
* ensure another of the same name may be created after removal;
Expand All @@ -277,8 +288,10 @@ static void test_named_delete(abts_case *tc, void *data)
APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);
}

#ifndef WIN32
rv = apr_shm_destroy(shm);
APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);
#endif

/* Now ensure no named resource remains which we may attach to */
rv = apr_shm_attach(&shm, SHARED_FILENAME, p);
Expand Down
Loading