summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-06-15 22:42:52 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-06-15 22:42:52 -0700
commit35e6d6867c63ad254e95325206aa7a927edd6797 (patch)
treef97feb4c06ceed98684b0431931c2eb6403d3999
parent552bd670071b519d97124621a3c11dc98062c12b (diff)
parent0887b8c2e583e682cd2c1bc909cb3fdbec704004 (diff)
downloadframeworks_base-35e6d6867c63ad254e95325206aa7a927edd6797.zip
frameworks_base-35e6d6867c63ad254e95325206aa7a927edd6797.tar.gz
frameworks_base-35e6d6867c63ad254e95325206aa7a927edd6797.tar.bz2
am 0887b8c2: am 8e18668d: revert surfaceflinger leak fix as it uncovered a crasher on xoom (DO NOT MERGE)
* commit '0887b8c2e583e682cd2c1bc909cb3fdbec704004': revert surfaceflinger leak fix as it uncovered a crasher on xoom (DO NOT MERGE)
-rw-r--r--include/utils/RefBase.h14
-rw-r--r--libs/utils/RefBase.cpp44
-rw-r--r--services/surfaceflinger/Layer.cpp5
-rw-r--r--services/surfaceflinger/Layer.h3
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp28
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h6
6 files changed, 10 insertions, 90 deletions
diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h
index c0be597..b31e993 100644
--- a/include/utils/RefBase.h
+++ b/include/utils/RefBase.h
@@ -117,20 +117,6 @@ public:
typedef RefBase basetype;
- // used to override the RefBase destruction.
- class Destroyer {
- friend class RefBase;
- friend class weakref_type;
- public:
- virtual ~Destroyer();
- private:
- virtual void destroy(RefBase const* base) = 0;
- };
-
- // Make sure to never acquire a strong reference from this function. The
- // same restrictions than for destructors apply.
- void setDestroyer(Destroyer* destroyer);
-
protected:
RefBase();
virtual ~RefBase();
diff --git a/libs/utils/RefBase.cpp b/libs/utils/RefBase.cpp
index 8db2009..2034486 100644
--- a/libs/utils/RefBase.cpp
+++ b/libs/utils/RefBase.cpp
@@ -49,11 +49,6 @@ namespace android {
// ---------------------------------------------------------------------------
-RefBase::Destroyer::~Destroyer() {
-}
-
-// ---------------------------------------------------------------------------
-
class RefBase::weakref_impl : public RefBase::weakref_type
{
public:
@@ -61,7 +56,7 @@ public:
volatile int32_t mWeak;
RefBase* const mBase;
volatile int32_t mFlags;
- Destroyer* mDestroyer;
+
#if !DEBUG_REFS
@@ -70,7 +65,6 @@ public:
, mWeak(0)
, mBase(base)
, mFlags(0)
- , mDestroyer(0)
{
}
@@ -363,11 +357,7 @@ void RefBase::decStrong(const void* id) const
if (c == 1) {
const_cast<RefBase*>(this)->onLastStrongRef(id);
if ((refs->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) {
- if (refs->mDestroyer) {
- refs->mDestroyer->destroy(this);
- } else {
- delete this;
- }
+ delete this;
}
}
refs->decWeak(id);
@@ -400,9 +390,7 @@ int32_t RefBase::getStrongCount() const
return mRefs->mStrong;
}
-void RefBase::setDestroyer(RefBase::Destroyer* destroyer) {
- mRefs->mDestroyer = destroyer;
-}
+
RefBase* RefBase::weakref_type::refBase() const
{
@@ -426,28 +414,16 @@ void RefBase::weakref_type::decWeak(const void* id)
if (c != 1) return;
if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) {
- if (impl->mStrong == INITIAL_STRONG_VALUE) {
- if (impl->mBase) {
- if (impl->mDestroyer) {
- impl->mDestroyer->destroy(impl->mBase);
- } else {
- delete impl->mBase;
- }
- }
- } else {
+ if (impl->mStrong == INITIAL_STRONG_VALUE)
+ delete impl->mBase;
+ else {
// LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase);
delete impl;
}
} else {
impl->mBase->onLastWeakRef(id);
if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) {
- if (impl->mBase) {
- if (impl->mDestroyer) {
- impl->mDestroyer->destroy(impl->mBase);
- } else {
- delete impl->mBase;
- }
- }
+ delete impl->mBase;
}
}
}
@@ -569,10 +545,8 @@ RefBase::RefBase()
RefBase::~RefBase()
{
- if ((mRefs->mFlags & OBJECT_LIFETIME_WEAK) == OBJECT_LIFETIME_WEAK) {
- if (mRefs->mWeak == 0) {
- delete mRefs;
- }
+ if (mRefs->mWeak == 0) {
+ delete mRefs;
}
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 78ca3c6..edef53a 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -61,7 +61,6 @@ Layer::Layer(SurfaceFlinger* flinger,
mBufferManager(mTextureManager),
mWidth(0), mHeight(0), mNeedsScaling(false), mFixedSize(false)
{
- setDestroyer(this);
}
Layer::~Layer()
@@ -78,10 +77,6 @@ Layer::~Layer()
}
}
-void Layer::destroy(RefBase const* base) {
- mFlinger->destroyLayer(static_cast<LayerBase const*>(base));
-}
-
status_t Layer::setToken(const sp<UserClient>& userClient,
SharedClient* sharedClient, int32_t token)
{
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 5330c08..4c92278 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -44,7 +44,7 @@ class UserClient;
// ---------------------------------------------------------------------------
-class Layer : public LayerBaseClient, private RefBase::Destroyer
+class Layer : public LayerBaseClient
{
public:
Layer(SurfaceFlinger* flinger, DisplayID display,
@@ -92,7 +92,6 @@ public:
return mFreezeLock; }
protected:
- virtual void destroy(RefBase const* base);
virtual void dump(String8& result, char* scratch, size_t size) const;
private:
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a7b5857..33cb9a4 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -387,9 +387,6 @@ bool SurfaceFlinger::threadLoop()
{
waitForEvent();
- // call Layer's destructor
- handleDestroyLayers();
-
// check for transactions
if (UNLIKELY(mConsoleSignals)) {
handleConsoleEvents();
@@ -583,31 +580,6 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
commitTransaction();
}
-void SurfaceFlinger::destroyLayer(LayerBase const* layer)
-{
- Mutex::Autolock _l(mDestroyedLayerLock);
- mDestroyedLayers.add(layer);
- signalEvent();
-}
-
-void SurfaceFlinger::handleDestroyLayers()
-{
- Vector<LayerBase const *> destroyedLayers;
-
- { // scope for the lock
- Mutex::Autolock _l(mDestroyedLayerLock);
- destroyedLayers = mDestroyedLayers;
- mDestroyedLayers.clear();
- }
-
- // call destructors without a lock held
- const size_t count = destroyedLayers.size();
- for (size_t i=0 ; i<count ; i++) {
- //LOGD("destroying %s", destroyedLayers[i]->getName().string());
- delete destroyedLayers[i];
- }
-}
-
sp<FreezeLock> SurfaceFlinger::getFreezeLock() const
{
return new FreezeLock(const_cast<SurfaceFlinger *>(this));
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index f81b074..31c20d7 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -233,7 +233,6 @@ public:
status_t addLayer(const sp<LayerBase>& layer);
status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
void invalidateHwcGeometry();
- void destroyLayer(LayerBase const* layer);
sp<Layer> getLayer(const sp<ISurface>& sur) const;
@@ -307,7 +306,6 @@ private:
void handleConsoleEvents();
void handleTransaction(uint32_t transactionFlags);
void handleTransactionLocked(uint32_t transactionFlags);
- void handleDestroyLayers();
void computeVisibleRegions(
LayerVector& currentLayers,
@@ -430,10 +428,6 @@ private:
mutable Barrier mReadyToRunBarrier;
- // protected by mDestroyedLayerLock;
- mutable Mutex mDestroyedLayerLock;
- Vector<LayerBase const *> mDestroyedLayers;
-
// atomic variables
enum {
eConsoleReleased = 1,