From: Przemyslaw Ciezkowski
Date: Fri, 23 Nov 2012 08:50:48 +0000 (+0100)
Subject: Throw an exception when pthread_key_create fails
X-Git-Tag: submit/trunk/20121123.130303~1
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ada933fa6f725548cb46c3654527047c6b0839a;p=platform%2Fframework%2Fweb%2Fwrt-commons.git
Throw an exception when pthread_key_create fails
[Issue#] TWEB-427
[Feature] ThreadLocalVariable should not call Assert
when pthread_key_create fails
[Cause] Process gets SIGABORT when ThreadLocalVariable fails.
[Solution] Replace with exception, allow to catch it.
[Verification] Run iframes.wgt widget from wrt-extra repository.
WebProcess should not fail when counter in widget hits ~160.
Verification requires patch from plugins_common where this excepion is handled.
Change-Id: I7205afcaed091732f0233500e58d596fed1bdf4f
---
diff --git a/modules/core/include/dpl/thread.h b/modules/core/include/dpl/thread.h
index 422239d..8406282 100644
--- a/modules/core/include/dpl/thread.h
+++ b/modules/core/include/dpl/thread.h
@@ -234,6 +234,7 @@ public:
public:
DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
DECLARE_EXCEPTION_TYPE(Base, NullReference)
+ DECLARE_EXCEPTION_TYPE(Base, KeyCreateFailed)
};
private:
@@ -310,9 +311,10 @@ public:
ThreadLocalVariable()
{
int result = pthread_key_create(&m_key, &InternalDestroy);
-
- Assert(result == 0 &&
- "Failed to allocate thread local variable");
+ if (result != 0) {
+ ThrowMsg(typename Exception::KeyCreateFailed,
+ "Failed to allocate thread local variable: " << result);
+ }
}
~ThreadLocalVariable()