Skip to content

Commit

Permalink
Merge pull request #122 from jkour/Pool-AV
Browse files Browse the repository at this point in the history
[pool] An AV occurs in TPoolItem
  • Loading branch information
exilon authored Oct 15, 2024
2 parents 92e8f5d + 815fe83 commit 3fb5b84
Show file tree
Hide file tree
Showing 2 changed files with 410 additions and 266 deletions.
8 changes: 4 additions & 4 deletions Quick.Pooling.pas
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,22 @@ function TPoolItem<T>._AddRef: Integer;

function TPoolItem<T>._Release: Integer;
begin
fLock.Enter;
{$IFDEF DEBUG_OBJPOOL}
TDebugger.Trace(Self,'Released Pool item');
{$ENDIF}
try
Dec(fRefCount);
Result := fRefCount;
result:=AtomicDecrement(fRefCount);
if Result = 0 then
begin
FreeAndNil(fItem);
// The following is take from TInterfacedObject._Release()
// Mark the refcount field so that any refcounting during destruction doesn't infinitely recurse.
__MarkDestroying(Self);
Destroy;
end
else fLastAccess := Now;
finally
if fRefCount = 1 then fSemaphore.Release;
fLock.Leave;
end;
end;

Expand Down
Loading

0 comments on commit 3fb5b84

Please sign in to comment.