]> source.dussan.org Git - tigervnc.git/commitdiff
Protect PlatformPixelBuffer from simultaneous access
authorPierre Ossman <ossman@cendio.se>
Fri, 13 Nov 2015 13:09:27 +0000 (14:09 +0100)
committerPierre Ossman <ossman@cendio.se>
Fri, 27 Nov 2015 10:13:31 +0000 (11:13 +0100)
The damage tracking region needs to be protected from multiple
threads accessing it at once. The rest should be fine though.

vncviewer/PlatformPixelBuffer.cxx
vncviewer/PlatformPixelBuffer.h

index 5bd50d2c6e9f67912d6895a45737b3adad431b33..522bad3f9755580d64c2d6062d4b343d5f2f2360 100644 (file)
@@ -28,15 +28,19 @@ PlatformPixelBuffer::PlatformPixelBuffer(const rfb::PixelFormat& pf,
 void PlatformPixelBuffer::commitBufferRW(const rfb::Rect& r)
 {
   FullFramePixelBuffer::commitBufferRW(r);
+  mutex.lock();
   damage.assign_union(rfb::Region(r));
+  mutex.unlock();
 }
 
 rfb::Rect PlatformPixelBuffer::getDamage(void)
 {
   rfb::Rect r;
 
+  mutex.lock();
   r = damage.get_bounding_rect();
   damage.clear();
+  mutex.unlock();
 
   return r;
 }
index 21b93be406c4d5a563f148884832f0e37f955c3c..795273a9bea4fc025f19144f559d06a990c56050 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef __PLATFORMPIXELBUFFER_H__
 #define __PLATFORMPIXELBUFFER_H__
 
+#include <os/Mutex.h>
+
 #include <rfb/PixelBuffer.h>
 #include <rfb/Region.h>
 
@@ -33,6 +35,7 @@ public:
   rfb::Rect getDamage(void);
 
 protected:
+  os::Mutex mutex;
   rfb::Region damage;
 };