diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-05 18:53:55 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-05 18:53:55 +0000 |
commit | 27f0408c4f70941c59c17e723acc2682bedbf6a3 (patch) | |
tree | e381e141eb6f6789069ef1d7b41f6b38f570ad80 /ui/surface | |
parent | 241e7f3505a993b73c477616d355fc59b9218f05 (diff) | |
download | chromium_src-27f0408c4f70941c59c17e723acc2682bedbf6a3.zip chromium_src-27f0408c4f70941c59c17e723acc2682bedbf6a3.tar.gz chromium_src-27f0408c4f70941c59c17e723acc2682bedbf6a3.tar.bz2 |
Keep track of which transport DIBs are currently in the X servers queue
Since X11 is asynchronous, there might be operations on the shared memory pending. If we unmap the shared memory immediately, the queued operations will make the renderer crash.
This can happen if a renderer is brought up, renderers a single frame, and is immediately destroyed again.
BUG=143580
TEST=running layout tests using content shell doesn't crash constantly
Review URL: https://chromiumcodereview.appspot.com/11014018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/surface')
-rw-r--r-- | ui/surface/transport_dib.h | 11 | ||||
-rw-r--r-- | ui/surface/transport_dib_linux.cc | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/ui/surface/transport_dib.h b/ui/surface/transport_dib.h index 3495c9d..70928ed 100644 --- a/ui/surface/transport_dib.h +++ b/ui/surface/transport_dib.h @@ -194,6 +194,15 @@ class SURFACE_EXPORT TransportDIB { // Map the shared memory into the X server and return an id for the shared // segment. XID MapToX(Display* connection); + + void IncreaseInFlightCounter() { inflight_counter_++; } + // Decreases the inflight counter, and deletes the transport DIB if it is + // detached. + void DecreaseInFlightCounter(); + + // Deletes this transport DIB and detaches the shared memory once the + // |inflight_counter_| is zero. + void Detach(); #endif private: @@ -207,6 +216,8 @@ class SURFACE_EXPORT TransportDIB { void* address_; // mapped address XSharedMemoryId x_shm_; // X id for the shared segment Display* display_; // connection to the X server + size_t inflight_counter_; // How many requests to the X server are in flight + bool detached_; // If true, delete the transport DIB when it is idle #endif size_t size_; // length, in bytes diff --git a/ui/surface/transport_dib_linux.cc b/ui/surface/transport_dib_linux.cc index b1a5469..7763c0e 100644 --- a/ui/surface/transport_dib_linux.cc +++ b/ui/surface/transport_dib_linux.cc @@ -22,6 +22,8 @@ TransportDIB::TransportDIB() : address_(kInvalidAddress), x_shm_(0), display_(NULL), + inflight_counter_(0), + detached_(false), size_(0) { } @@ -138,3 +140,17 @@ XID TransportDIB::MapToX(Display* display) { return x_shm_; } + +void TransportDIB::DecreaseInFlightCounter() { + CHECK(inflight_counter_); + inflight_counter_--; + if (!inflight_counter_ && detached_) + delete this; +} + +void TransportDIB::Detach() { + CHECK(!detached_); + detached_ = true; + if (!inflight_counter_) + delete this; +} |