damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit c7cc8df5bac5a64eb7468bae8c3e798c981fc12f
parent 92df446d7210c6f8e954aaaf6e539232e738b5d0
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 11 Dec 2023 14:43:12 -0800

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.

Diffstat:
Mnostrdb/nostrdb.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/nostrdb/nostrdb.c b/nostrdb/nostrdb.c @@ -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)