[Kst] branches/work/kst/hierarchy/kst/src/libkst

Eli Fidler eli at staikos.net
Fri Dec 15 21:33:52 CET 2006


SVN commit 613954 by fidler:

fix readLock so that recursive read locks aren't blocked by waiting
writers. The writer priority causes a deadlock.


 M  +9 -4      rwlock.cpp  


--- branches/work/kst/hierarchy/kst/src/libkst/rwlock.cpp #613953:613954
@@ -51,10 +51,15 @@
     kstdDebug() << "Thread " << (int)QThread::currentThread() << " has a write lock on KstRWLock " << (void*)this << ", getting a read lock" << endl;
 #endif
   } else {
-    while (_writeCount > 0 || _waitingWriters) {
-      ++_waitingReaders;
-      _readerWait.wait(&_mutex);
-      --_waitingReaders;
+    QMap<Qt::HANDLE, int>::Iterator it = _readLockers.find(me);
+    if (it != _readLockers.end() && it.data() > 0) {
+      // thread already has another read lock
+    } else {
+      while (_writeCount > 0 || _waitingWriters) {  // writer priority otherwise
+        ++_waitingReaders;
+        _readerWait.wait(&_mutex);
+        --_waitingReaders;
+      }
     }
   }
 


More information about the Kst mailing list