Explorar el Código

* 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 -

Jonas Maebe hace 15 años
padre
commit
8da0a031bf
Se han modificado 2 ficheros con 18 adiciones y 1 borrados
  1. 2 1
      rtl/objpas/sysutils/sysuthrd.inc
  2. 16 0
      tests/test/units/sysutils/trwsync.pp

+ 2 - 1
rtl/objpas/sysutils/sysuthrd.inc

@@ -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

+ 16 - 0
tests/test/units/sysutils/trwsync.pp

@@ -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.