server: lock run_query

So the query-results don't outlive the lock.
This commit is contained in:
Dirk-Jan C. Binnema 2022-02-17 23:46:44 +02:00
parent 831d26052a
commit 80f947024a
1 changed files with 2 additions and 0 deletions

View File

@ -566,6 +566,7 @@ docids_for_msgid(const Store& store, const std::string& msgid, size_t max = 100)
g_free(tmp);
GError* gerr{};
std::lock_guard l{store.lock()};
const auto res{store.run_query(expr, MU_MSG_FIELD_ID_NONE, QueryFlags::None, max)};
g_free(expr);
if (!res)
@ -692,6 +693,7 @@ Server::Private::find_handler(const Parameters& params)
if (threads)
qflags |= QueryFlags::Threading;
std::lock_guard l{store_.lock()};
auto qres{store_.run_query(q, sort_field, qflags, maxnum)};
if (!qres)
throw Error(Error::Code::Query, "failed to run query");