• R/O
  • SSH
  • HTTPS

eirrepo: Commit


Commit MetaInfo

Revision156 (tree)
Time2018-11-28 22:59:08
Authorquiret

Log Message

- fixed a bug in DTS where deleting types that had types which inherited from it would cause crashes
- adjusted some code in PluginFactory.h to improve debugging

Change Summary

Incremental Difference

--- common/sdk/DynamicTypeSystem.h (revision 155)
+++ common/sdk/DynamicTypeSystem.h (revision 156)
@@ -570,25 +570,30 @@
570570 return info;
571571 }
572572
573- // THREAD-SAFE because memory allocation is THREAD-SAFE and type registration is THREAD-SAFE.
574- template <typename structTypeTypeInterface, typename... constrArgs>
575- inline typeInfoBase* RegisterCommonTypeInterface( const char *typeName, typeInfoBase *inheritsFrom = nullptr, constrArgs... args )
573+ // Do no manually construct or destroy this class.
574+ template <typename structTypeTypeInterface>
575+ struct commonTypeInfoStruct : public typeInfoBase
576576 {
577- struct typeInfoStruct : public typeInfoBase
577+ template <typename... constrArgs>
578+ AINLINE commonTypeInfoStruct( constrArgs... args ) : tInterface( std::forward <constrArgs> ( args )... )
578579 {
579- AINLINE typeInfoStruct( constrArgs... args ) : tInterface( std::forward <constrArgs> ( args )... )
580- {
581- return;
582- }
580+ return;
581+ }
583582
584- void Cleanup( void ) override
585- {
586- eir::static_del_struct <typeInfoStruct, allocatorType> ( this->typeSys, this );
587- }
583+ void Cleanup( void ) override
584+ {
585+ eir::static_del_struct <commonTypeInfoStruct, allocatorType> ( this->typeSys, this );
586+ }
588587
589- structTypeTypeInterface tInterface;
590- };
591-
588+ structTypeTypeInterface tInterface;
589+ };
590+
591+ // THREAD-SAFE because memory allocation is THREAD-SAFE and type registration is THREAD-SAFE.
592+ template <typename structTypeTypeInterface, typename... constrArgs>
593+ inline commonTypeInfoStruct <structTypeTypeInterface>* RegisterCommonTypeInterface( const char *typeName, typeInfoBase *inheritsFrom = nullptr, constrArgs... args )
594+ {
595+ typedef commonTypeInfoStruct <structTypeTypeInterface> typeInfoStruct;
596+
592597 typeInfoStruct *tInfo = eir::static_new_struct <typeInfoStruct, allocatorType> ( this, std::forward <constrArgs> ( args )... );
593598
594599 if ( tInfo == nullptr )
@@ -1362,6 +1367,7 @@
13621367
13631368 // Make sure we can even do that.
13641369 // Verify that no other type with that name exists which inherits from said class.
1370+ if ( inheritedClass != nullptr )
13651371 {
13661372 typeInfoBase *alreadyExisting = FindTypeInfoNolock( subClass->name, inheritedClass );
13671373
@@ -1579,13 +1585,13 @@
15791585
15801586 // Make sure all classes that inherit from us do not do that anymore.
15811587 {
1582- scoped_rwlock_read typeEnvironmentConsistencyLock( this->lockProvider, this->mainLock );
1588+ scoped_rwlock_write typeEnvironmentConsistencyLock( this->lockProvider, this->mainLock );
15831589
15841590 LIST_FOREACH_BEGIN( typeInfoBase, this->registeredTypes.root, node )
15851591
15861592 if ( item->inheritsFrom == typeInfo )
15871593 {
1588- SetTypeInfoInheritingClass( item, nullptr );
1594+ SetTypeInfoInheritingClass( item, nullptr, false );
15891595 }
15901596
15911597 LIST_FOREACH_END
--- common/sdk/PluginFactory.h (revision 155)
+++ common/sdk/PluginFactory.h (revision 156)
@@ -243,19 +243,19 @@
243243
244244 inline void DestroyPluginBlockInternal( abstractionType *pluginObj, regionIterator_t& iter, AdditionalArgs... addArgs )
245245 {
246- try
246+ while ( true )
247247 {
248- while ( true )
249- {
250- iter.Decrement();
248+ iter.Decrement();
251249
252- if ( iter.IsEnd() )
253- break;
250+ if ( iter.IsEnd() )
251+ break;
254252
255- const blockAlloc_t::block_t *blockItem = iter.ResolveBlock();
253+ const blockAlloc_t::block_t *blockItem = iter.ResolveBlock();
256254
257- const registered_plugin *constructedInfo = (const registered_plugin*)blockItem;
255+ const registered_plugin *constructedInfo = (const registered_plugin*)blockItem;
258256
257+ try
258+ {
259259 // Destroy that plugin again.
260260 constructedInfo->descriptor->OnPluginDestruct(
261261 pluginObj,
@@ -264,12 +264,12 @@
264264 addArgs...
265265 );
266266 }
267+ catch( ... )
268+ {
269+ // We must not fail destruction, in any way.
270+ assert( 0 );
271+ }
267272 }
268- catch( ... )
269- {
270- // We must not fail destruction, in any way.
271- assert( 0 );
272- }
273273 }
274274
275275 public:
Show on old repository browser