Skip to content

Commit 1868a84

Browse files
committed
Merge bitcoin-core#245: type-context.h: Extent cancel_mutex lock to prevent theoretical race
ef96a5b doc: Comment cleanups after bitcoin-core#240 (Ryan Ofsky) e0f1cd7 type-context.h: Extent cancel_mutex lock to prevent theoretical race (Ryan Ofsky) Pull request description: This is a followup to bitcoin-core#240 that fixes a theoretical race condition in that PR pointed out by janb bitcoin/bitcoin#34422 (comment). Details are in the commit message. There is also an additional commit fixing up some documentation added in that PR ACKs for top commit: Sjors: ACK ef96a5b Tree-SHA512: 9d3c1585b7e1862a3b2bada48f72c389cf5d60cc72aa348c83fe87fb8f05287971216fc561a4334140df4a8d2bcc28f5256dd733ff3fb4ec08aa72e57d136963
2 parents fd4a90d + ef96a5b commit 1868a84

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/mp/type-context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
123123
// it. So in addition to locking the mutex, the
124124
// execution thread always checks request_canceled
125125
// as well before accessing the structs.
126-
Lock{cancel_mutex};
126+
Lock cancel_lock{cancel_mutex};
127127
server_context.request_canceled = true;
128128
};
129129
// Update requests_threads map if not canceled.
@@ -210,7 +210,7 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
210210
// connection is destroyed. (By default Cap'n Proto does not cancel requests
211211
// on disconnect, since it's possible clients might want to make requests
212212
// and immediately disconnect without waiting for results, but not want the
213-
// the requests to be canceled.)
213+
// requests to be canceled.)
214214
return server.m_context.connection->m_canceler.wrap(kj::mv(result));
215215
}
216216
} // namespace mp

include/mp/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void CancelMonitor::promiseDestroyed(CancelProbe& probe)
331331
// theory this method could be called when a promise was fulfilled or
332332
// rejected rather than canceled, but it's safe to assume that's not the
333333
// case because the CancelMonitor class is meant to be used inside code
334-
// fulfilling or rejecting the promise and destroyed before doing these.
334+
// fulfilling or rejecting the promise and destroyed before doing so.
335335
assert(m_probe == &probe);
336336
m_canceled = true;
337337
if (m_on_cancel) m_on_cancel();

0 commit comments

Comments
 (0)