Skip to content

Commit

Permalink
capicxx-core-tools 3.1.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent 1bcfad8 commit 7e295ad
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Changes
=======
v3.1.12.2
- Reworked attribute locking in StubAdapter to prevent deadlock

v3.1.12.1
- Fixed data race in generated StubDefault when using attributes
- Fix extended unions with custom data types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,16 @@ class FInterfaceStubGenerator {

virtual void deactivateManagedInstances() = 0;

void lockAttributes() {
«IF !fInterface.attributes.empty»
attributesMutex_.lock();
«ENDIF»
}
«FOR attribute : fInterface.attributes»
void «attribute.stubClassLockMethodName»(bool _lockAccess) {
if (_lockAccess) {
«attribute.stubAdapterAttributeMutexName».lock();
} else {
«attribute.stubAdapterAttributeMutexName».unlock();
}
}
«ENDFOR»

void unlockAttributes() {
«IF !fInterface.attributes.empty»
attributesMutex_.unlock();
«ENDIF»
}
protected:
/**
* Defines properties for storing the ClientIds of clients / proxies that have
Expand All @@ -161,9 +160,9 @@ class FInterfaceStubGenerator {
«ENDIF»
«ENDFOR»

«IF !fInterface.attributes.empty»
std::mutex attributesMutex_;
«ENDIF»
«FOR attribute : fInterface.attributes»
std::recursive_mutex «attribute.stubAdapterAttributeMutexName»;
«ENDFOR»
};

/**
Expand Down Expand Up @@ -217,6 +216,7 @@ class FInterfaceStubGenerator {

virtual ~«fInterface.stubClassName»() {}
virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0;
void lockInterfaceVersionAttribute(bool _lockAccess) { static_cast<void>(_lockAccess); }

«FOR attribute : fInterface.attributes»
«FTypeGenerator::generateComments(attribute, false
Expand All @@ -234,6 +234,11 @@ class FInterfaceStubGenerator {
stubAdapter->«attribute.stubAdapterClassFireChangedMethodName»(_value);
}
«ENDIF»
void «attribute.stubClassLockMethodName»(bool _lockAccess) {
auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
if (stubAdapter)
stubAdapter->«attribute.stubClassLockMethodName»(_lockAccess);
}
«ENDFOR»

«FOR method: fInterface.methods»
Expand Down Expand Up @@ -560,10 +565,10 @@ class FInterfaceStubGenerator {
bool valueChanged;
std::shared_ptr<«fInterface.stubAdapterClassName»> stubAdapter = CommonAPI::Stub<«fInterface.stubAdapterClassName», «fInterface.stubRemoteEventClassName»>::stubAdapter_.lock();
if(stubAdapter) {
stubAdapter->lockAttributes();
stubAdapter->«attribute.stubClassLockMethodName»(true);
valueChanged = («attribute.stubDefaultClassVariableName» != _value);
«attribute.stubDefaultClassVariableName» = std::move(_value);
stubAdapter->unlockAttributes();
stubAdapter->«attribute.stubClassLockMethodName»(false);
} else {
valueChanged = («attribute.stubDefaultClassVariableName» != _value);
«attribute.stubDefaultClassVariableName» = std::move(_value);
Expand Down Expand Up @@ -721,4 +726,8 @@ class FInterfaceStubGenerator {
def private getStubDefaultClassVariableName(FAttribute fAttribute) {
fAttribute.elementName.toFirstLower + 'AttributeValue_'
}
def private getStubAdapterAttributeMutexName(FAttribute fAttribute) {
fAttribute.elementName.toFirstLower + 'Mutex_'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,10 @@ class FrancaGeneratorExtensions {
'onRemote' + fAttribute.elementName.toFirstUpper + 'AttributeChanged'
}

def getStubClassLockMethodName(FAttribute fAttribute) {
'lock' + fAttribute.elementName.toFirstUpper + 'Attribute'
}

def getStubClassGetMethodName(FAttribute fAttribute) {
'get' + fAttribute.elementName.toFirstUpper + 'Attribute'
}
Expand Down

0 comments on commit 7e295ad

Please sign in to comment.