File openwbem-3.1.0-friend-injection.patch of Package openwbem
--- ./src/common/OW_COWIntrusiveCountableBase.hpp.friend_orig 2005-10-19 17:38:49.000000000 -0600
+++ ./src/common/OW_COWIntrusiveCountableBase.hpp 2005-10-19 17:38:17.000000000 -0600
@@ -57,6 +57,12 @@
*
* Derived classes must implement: Derived* clone()
*/
+class COWIntrusiveCountableBase;
+void COWIntrusiveReferenceAddRef(COWIntrusiveCountableBase * p);
+void COWIntrusiveReferenceRelease(COWIntrusiveCountableBase * p);
+bool COWIntrusiveReferenceUnique(COWIntrusiveCountableBase* p);
+template <typename T> T* COWIntrusiveReferenceClone(T* p);
+
class OW_COMMON_API COWIntrusiveCountableBase
{
private:
@@ -100,30 +106,32 @@
{
return p->m_usecount.get() == 1;
}
-
template <typename T>
- inline friend T* COWIntrusiveReferenceClone(T* p)
+ friend T* COWIntrusiveReferenceClone(T* p);
+
+};
+template <typename T>
+inline T* COWIntrusiveReferenceClone(T* p)
+{
+ // this needs to happen first to avoid a race condition between
+ // another thread deleting the object and this one making a copy.
+ T* tmp = p->clone();
+ if (p->m_usecount.decAndTest())
{
- // this needs to happen first to avoid a race condition between
- // another thread deleting the object and this one making a copy.
- T* tmp = p->clone();
- if (p->m_usecount.decAndTest())
- {
- // only copy--don't need to clone, also not a race condition.
- // undo the decAndTest.
- p->m_usecount.inc();
- delete tmp; // we won't need this anymore.
- return p;
- }
- else
- {
- // need to become unique
- if (tmp) COWIntrusiveReferenceAddRef(tmp);
+ // only copy--don't need to clone, also not a race condition.
+ // undo the decAndTest.
+ p->m_usecount.inc();
+ delete tmp; // we won't need this anymore.
+ return p;
+ }
+ else
+ {
+ // need to become unique
+ if (tmp) COWIntrusiveReferenceAddRef(tmp);
- return tmp;
- }
+ return tmp;
}
-};
+}
} // end namespace OpenWBEM
--- ./src/common/OW_IntrusiveCountableBase.hpp.friend_orig 2005-10-19 17:39:18.000000000 -0600
+++ ./src/common/OW_IntrusiveCountableBase.hpp 2005-10-19 17:39:55.000000000 -0600
@@ -55,6 +55,11 @@
* from this class. Note that if multiple inheritance is used, you must derive
* "virtual"ly.
*/
+
+class IntrusiveCountableBase;
+void IntrusiveReferenceAddRef(IntrusiveCountableBase * p);
+void IntrusiveReferenceRelease(IntrusiveCountableBase * p);
+
class OW_COMMON_API IntrusiveCountableBase
{
private:
--- ./src/providerifcs/cmpi/common/cmpiThreadContext.h.friend_orig 2004-08-04 14:20:10.000000000 -0600
+++ ./src/providerifcs/cmpi/common/cmpiThreadContext.h 2005-10-19 14:15:59.000000000 -0600
@@ -32,6 +32,7 @@
#include "cmpift.h"
#include "cmpisrv.h"
+void initializeTheKey();
class CMPI_ThreadContext {
static pthread_key_t theKey;