RemoteStore::addCAToStore(): Don't hold connection while calling queryPathInfo()

This leads to a deadlock if we're at the connection limit.
This commit is contained in:
Eelco Dolstra 2020-09-22 15:28:20 +02:00
parent 5b107f2c5f
commit 980edd1f3a

View file

@ -541,7 +541,8 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
const StorePathSet & references, const StorePathSet & references,
RepairFlag repair) RepairFlag repair)
{ {
auto conn(getConnection()); std::optional<ConnectionHandle> conn_(getConnection());
auto & conn = *conn_;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 25) { if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 25) {
@ -605,6 +606,8 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
} }
}, caMethod); }, caMethod);
auto path = parseStorePath(readString(conn->from)); auto path = parseStorePath(readString(conn->from));
// Release our connection to prevent a deadlock in queryPathInfo().
conn_.reset();
return queryPathInfo(path); return queryPathInfo(path);
} }
} }