Merge pull request #4937 from apple/anoyes/allow-flow-lock-kill-to-delete-self

Allow FlowLock::kill to delete self
This commit is contained in:
Steve Atherton 2021-06-09 12:31:31 -07:00 committed by GitHub
commit 82a9bdbbaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -1348,7 +1348,9 @@ struct FlowLock : NonCopyable, public ReferenceCounted<FlowLock> {
// Only works if broken_on_destruct.canBeSet()
void kill(Error e = broken_promise()) {
if (broken_on_destruct.canBeSet()) {
broken_on_destruct.sendError(e);
auto local = broken_on_destruct;
// It could be the case that calling broken_on_destruct destroys this FlowLock
local.sendError(e);
}
}