* fixed memory leak in new TMultiReadExclusiveWriteSynchronizer

(fwaitingwriterlock was not freed)
  * fixed typo in comment
  * free all memory in trwsync.pp test

git-svn-id: trunk@14588 -
This commit is contained in:
Jonas Maebe 2010-01-09 23:14:53 +00:00
parent 106baa8b2f
commit 8da0a031bf
2 changed files with 18 additions and 1 deletions

View File

@ -61,6 +61,7 @@ destructor TMultiReadExclusiveWriteSynchronizer.Destroy;
begin
InterlockedExchange(fwritelocked,0);
RtlEventDestroy(fwritelock);
RtlEventDestroy(fwaitingwriterlock);
BasicEventDestroy(freaderqueue);
end;
@ -125,7 +126,7 @@ begin
{ wait until there is no more writer }
while InterLockedExchangeAdd(fwritelocked,0)<>0 do
begin
{ there's a writer busy or ir wanting to start -> wait until it's
{ there's a writer busy or wanting to start -> wait until it's
finished; a writer may already be blocked in the mean time, so
wake it up if we're the last to go to sleep }
if InterlockedDecrement(freadercount)=0 then

View File

@ -111,6 +111,11 @@ begin
if (gcount<>w1.localcount+w2.localcount+w3.localcount+w4.localcount) then
halt(1);
w1.free;
w2.free;
w3.free;
w4.free;
{ now try some mixed readers/writers }
gcount:=0;
r1:=treadcounter.create;
@ -143,4 +148,15 @@ begin
{ updating via the readcount must have caused data races }
if (gcount>=r1.localcount+r2.localcount+r3.localcount+r4.localcount+r5.localcount+r6.localcount+w1.localcount+w2.localcount) then
halt(2);
r1.free;
r2.free;
r3.free;
r4.free;
r5.free;
r6.free;
w1.free;
w2.free;
lock.free;
end.