Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8341ea5

Browse files
committed
Fix memory leak in Async.AwaitHandle -closesdotnet#131
1 parent93594b2 commit8341ea5

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

‎src/fsharp/FSharp.Core/control.fs‎

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,29 +1671,34 @@ namespace Microsoft.FSharp.Control
16711671
Action<obj>(fun _->
16721672
if latch.Enter()then
16731673
// if we got here - then we need to unregister RegisteredWaitHandle + trigger cancellation
1674-
// entrance to TP callback is protected by latch - so savedCont will never be called
1675-
match!rwhwith
1676-
| None->()
1677-
| Some rwh-> rwh.Unregister(null)|> ignore
1674+
// entrance to TP callback is protected by latch - so savedCont will never be called
1675+
lock rwh(fun()->
1676+
match!rwhwith
1677+
| None->()
1678+
| Some rwh-> rwh.Unregister(null)|> ignore)
16781679
Async.Start(async{do(aux.ccont(OperationCanceledException())|> unfake)}))
16791680

1680-
and registration: CancellationTokenRegistration= aux.token.Register(cancelHandler,null)
1681+
and registration: CancellationTokenRegistration= aux.token.Register(cancelHandler,null)
16811682

16821683
letsavedCont= args.cont
16831684
try
1684-
rwh:= Some(ThreadPool.RegisterWaitForSingleObject
1685-
(waitObject=waitHandle,
1686-
callBack=WaitOrTimerCallback(fun _ timeOut->
1687-
if latch.Enter()then
1688-
rwh:= None
1689-
registration.Dispose()
1690-
aux.trampolineHolder.Protect(fun()-> savedCont(not timeOut))|> unfake),
1691-
state=null,
1692-
millisecondsTimeOutInterval=millisecondsTimeout,
1693-
executeOnlyOnce=true));
1694-
FakeUnit
1685+
lock rwh(fun()->
1686+
rwh:= Some(ThreadPool.RegisterWaitForSingleObject
1687+
(waitObject=waitHandle,
1688+
callBack=WaitOrTimerCallback(fun _ timeOut->
1689+
if latch.Enter()then
1690+
lock rwh(fun()-> rwh.Value.Value.Unregister(null)|> ignore)
1691+
rwh:= None
1692+
registration.Dispose()
1693+
aux.trampolineHolder.Protect(fun()-> savedCont(not timeOut))|> unfake),
1694+
state=null,
1695+
millisecondsTimeOutInterval=millisecondsTimeout,
1696+
executeOnlyOnce=true));
1697+
FakeUnit)
16951698
with_->
1696-
if latch.Enter()then reraise()// reraise exception only if we successfully enter the latch (no other continuations were called)
1699+
if latch.Enter()then
1700+
registration.Dispose()
1701+
reraise()// reraise exception only if we successfully enter the latch (no other continuations were called)
16971702
else FakeUnit
16981703
)
16991704
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp