-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Probably this comment must be updated as well, because Backend
actually acquires the lock itself starting from this PR. Also maybe worth mentioning that no states should be destroyed when import lock is held (this seems a bit fragile)?
Good point. It would be better to lock it outside. |
client/src/call_executor.rs
Outdated
@@ -96,7 +96,10 @@ where | |||
None, | |||
) | |||
.map(|(result, _, _)| result)?; | |||
self.backend.destroy_state(state)?; | |||
{ | |||
let _ = self.backend.get_import_lock().read(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not correct. It drops immediately the lock!
It is also not required to create a sub context here, as the functions end after it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not correct. It drops immediately the lock!
How so? The RwLockReadGuard
returned by read
lives till the end of the block.
It is also not required to create a sub context here, as the functions end after it anyway.
Here it actually makes sense because we don't want to hold the lock for the duration of into_encoded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_best
functor was checked under cache lock, which was supposed to guarantee consistency. But in reality it does not, because cache is also updated when validating transactions outside of import lock. So this is removed.Rwlock
instead ofMutex
for extra performance.