nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit b00f9f05fcff3fc7477650e672e62344af3b9bb7
parent 39f36f9284dc92a51f1c3acb8ba497186252d1bb
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 11 Dec 2023 14:43:12 -0800

lmdb: don't begin query if we have a bad lmdb env

In some weird multithreaded situations after we close the database,
this can be an issue.

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mnostrdb.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/nostrdb.c b/nostrdb.c @@ -864,6 +864,8 @@ static int _ndb_begin_query(struct ndb *ndb, struct ndb_txn *txn, int flags) { txn->lmdb = &ndb->lmdb; MDB_txn **mdb_txn = (MDB_txn **)&txn->mdb_txn; + if (!txn->lmdb->env) + return 0; return mdb_txn_begin(txn->lmdb->env, NULL, flags, mdb_txn) == 0; }