nostrdb: mem: relay iter cleanup
This commit is contained in:
committed by
Daniel D’Aquino
parent
342067640f
commit
4d8313c788
@@ -3671,7 +3671,8 @@ static int ndb_query_plan_execute_ids(struct ndb_txn *txn,
|
|||||||
uint64_t note_id, until, *pint;
|
uint64_t note_id, until, *pint;
|
||||||
size_t note_size;
|
size_t note_size;
|
||||||
unsigned char *id;
|
unsigned char *id;
|
||||||
struct ndb_note_relay_iterator note_relay_iter;
|
struct ndb_note_relay_iterator note_relay_iter = {0};
|
||||||
|
struct ndb_note_relay_iterator *relay_iter = NULL;
|
||||||
|
|
||||||
until = UINT64_MAX;
|
until = UINT64_MAX;
|
||||||
|
|
||||||
@@ -3712,17 +3713,20 @@ static int ndb_query_plan_execute_ids(struct ndb_txn *txn,
|
|||||||
if (!(note = ndb_get_note_by_key(txn, note_id, ¬e_size)))
|
if (!(note = ndb_get_note_by_key(txn, note_id, ¬e_size)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (need_relays)
|
relay_iter = need_relays ? ¬e_relay_iter : NULL;
|
||||||
ndb_note_relay_iterate_start(txn, ¬e_relay_iter, note_id);
|
if (relay_iter)
|
||||||
|
ndb_note_relay_iterate_start(txn, relay_iter, note_id);
|
||||||
|
|
||||||
// Sure this particular lookup matched the index query, but
|
// Sure this particular lookup matched the index query, but
|
||||||
// does it match the entire filter? Check! We also pass in
|
// does it match the entire filter? Check! We also pass in
|
||||||
// things we've already matched via the filter so we don't have
|
// things we've already matched via the filter so we don't have
|
||||||
// to check again. This can be pretty important for filters
|
// to check again. This can be pretty important for filters
|
||||||
// with a large number of entries.
|
// with a large number of entries.
|
||||||
if (!ndb_filter_matches_with(filter, note, 1 << NDB_FILTER_IDS,
|
if (!ndb_filter_matches_with(filter, note, 1 << NDB_FILTER_IDS, relay_iter)) {
|
||||||
need_relays ? ¬e_relay_iter : NULL))
|
ndb_note_relay_iterate_close(relay_iter);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
ndb_note_relay_iterate_close(relay_iter);
|
||||||
|
|
||||||
ndb_query_result_init(&res, note, note_size, note_id);
|
ndb_query_result_init(&res, note, note_size, note_id);
|
||||||
if (!push_query_result(results, &res))
|
if (!push_query_result(results, &res))
|
||||||
@@ -3973,8 +3977,9 @@ static int ndb_query_plan_execute_tags(struct ndb_txn *txn,
|
|||||||
|
|
||||||
if (!(len = ndb_encode_tag_key(key_buffer, sizeof(key_buffer),
|
if (!(len = ndb_encode_tag_key(key_buffer, sizeof(key_buffer),
|
||||||
tags->field.tag, tag, taglen,
|
tags->field.tag, tag, taglen,
|
||||||
until)))
|
until))) {
|
||||||
return 0;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
k.mv_data = key_buffer;
|
k.mv_data = key_buffer;
|
||||||
k.mv_size = len;
|
k.mv_size = len;
|
||||||
@@ -4020,6 +4025,9 @@ next:
|
|||||||
|
|
||||||
mdb_cursor_close(cur);
|
mdb_cursor_close(cur);
|
||||||
return 1;
|
return 1;
|
||||||
|
fail:
|
||||||
|
mdb_cursor_close(cur);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ndb_query_plan_execute_author_kinds(
|
static int ndb_query_plan_execute_author_kinds(
|
||||||
|
|||||||
Reference in New Issue
Block a user