Merge pull request #1171 from neuroscr/fileonion

Put lock around buildNewOnionPaths
pull/1186/head
Ryan Tharp 5 years ago committed by GitHub
commit bbea23ed7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -408,11 +408,7 @@ class LokiSnodeAPI {
});
}
// FIXME: need a lock because it is being called multiple times in parallel
async buildNewOnionPaths() {
// Note: this function may be called concurrently, so
// might consider blocking the other calls
async buildNewOnionPathsWorker() {
const _ = window.Lodash;
log.info('LokiSnodeAPI::buildNewOnionPaths - building new onion paths');
@ -436,7 +432,9 @@ class LokiSnodeAPI {
if (this.guardNodes.length < edKeys.length) {
log.warn(
`LokiSnodeAPI::buildNewOnionPaths - could not find some guard nodes: ${this.guardNodes.length}/${edKeys.length} left`
`LokiSnodeAPI::buildNewOnionPaths - could not find some guard nodes: ${
this.guardNodes.length
}/${edKeys.length} left`
);
}
}
@ -490,6 +488,11 @@ class LokiSnodeAPI {
log.info(`Built ${this.onionPaths.length} onion paths`, this.onionPaths);
}
async buildNewOnionPaths() {
// this function may be called concurrently make sure we only have one inflight
return primitives.allowOnlyOneAtATime('buildNewOnionPaths', this.buildNewOnionPathsWorker);
}
async getRandomSnodeAddress() {
// resolve random snode
if (this.randomSnodePool.length === 0) {

Loading…
Cancel
Save