nostrdb: 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.
This commit is contained in:
William Casarin
2023-12-11 14:43:12 -08:00
parent 92df446d72
commit c7cc8df5ba

View File

@@ -864,7 +864,9 @@ 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;
return mdb_txn_begin(txn->lmdb->env, NULL, flags, mdb_txn) == 0;
if (!txn->lmdb->env)
return 0;
return mdb_txn_begin(txn->lmdb->env, NULL, flags, mdb_txn) == 0;
}
int ndb_begin_query(struct ndb *ndb, struct ndb_txn *txn)