Skip to content
Snippets Groups Projects
Commit f79aeb94 authored by mattijs's avatar mattijs
Browse files

ENH: Time: construct dlLibraryTable before reading dictionary so controlDict...

ENH: Time: construct dlLibraryTable before reading dictionary so controlDict can have e.g. #codeStream
parent 784e9f44
No related branches found
No related tags found
No related merge requests found
...@@ -228,6 +228,8 @@ Foam::Time::Time ...@@ -228,6 +228,8 @@ Foam::Time::Time
objectRegistry(*this), objectRegistry(*this),
libs_(),
controlDict_ controlDict_
( (
IOobject IOobject
...@@ -257,9 +259,10 @@ Foam::Time::Time ...@@ -257,9 +259,10 @@ Foam::Time::Time
graphFormat_("raw"), graphFormat_("raw"),
runTimeModifiable_(true), runTimeModifiable_(true),
libs_(controlDict_, "libs"),
functionObjects_(*this) functionObjects_(*this)
{ {
libs_.open(controlDict_, "libs");
// Explicitly set read flags on objectRegistry so anything constructed // Explicitly set read flags on objectRegistry so anything constructed
// from it reads as well (e.g. fvSolution). // from it reads as well (e.g. fvSolution).
readOpt() = IOobject::MUST_READ_IF_MODIFIED; readOpt() = IOobject::MUST_READ_IF_MODIFIED;
...@@ -313,6 +316,8 @@ Foam::Time::Time ...@@ -313,6 +316,8 @@ Foam::Time::Time
objectRegistry(*this), objectRegistry(*this),
libs_(),
controlDict_ controlDict_
( (
IOobject IOobject
...@@ -343,9 +348,11 @@ Foam::Time::Time ...@@ -343,9 +348,11 @@ Foam::Time::Time
graphFormat_("raw"), graphFormat_("raw"),
runTimeModifiable_(true), runTimeModifiable_(true),
libs_(controlDict_, "libs"),
functionObjects_(*this) functionObjects_(*this)
{ {
libs_.open(controlDict_, "libs");
// Explicitly set read flags on objectRegistry so anything constructed // Explicitly set read flags on objectRegistry so anything constructed
// from it reads as well (e.g. fvSolution). // from it reads as well (e.g. fvSolution).
readOpt() = IOobject::MUST_READ_IF_MODIFIED; readOpt() = IOobject::MUST_READ_IF_MODIFIED;
...@@ -401,6 +408,8 @@ Foam::Time::Time ...@@ -401,6 +408,8 @@ Foam::Time::Time
objectRegistry(*this), objectRegistry(*this),
libs_(),
controlDict_ controlDict_
( (
IOobject IOobject
...@@ -430,9 +439,10 @@ Foam::Time::Time ...@@ -430,9 +439,10 @@ Foam::Time::Time
graphFormat_("raw"), graphFormat_("raw"),
runTimeModifiable_(true), runTimeModifiable_(true),
libs_(controlDict_, "libs"),
functionObjects_(*this) functionObjects_(*this)
{} {
libs_.open(controlDict_, "libs");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......
...@@ -75,6 +75,10 @@ class Time ...@@ -75,6 +75,10 @@ class Time
//- file-change monitor for all registered files //- file-change monitor for all registered files
mutable autoPtr<fileMonitor> monitorPtr_; mutable autoPtr<fileMonitor> monitorPtr_;
//- Any loaded dynamic libraries. Make sure to construct before
// reading controlDict.
dlLibraryTable libs_;
//- The controlDict //- The controlDict
IOdictionary controlDict_; IOdictionary controlDict_;
...@@ -166,9 +170,6 @@ private: ...@@ -166,9 +170,6 @@ private:
//- Is runtime modification of dictionaries allowed? //- Is runtime modification of dictionaries allowed?
Switch runTimeModifiable_; Switch runTimeModifiable_;
//- Any loaded dynamic libraries
dlLibraryTable libs_;
//- Function objects executed at start and on ++, += //- Function objects executed at start and on ++, +=
mutable functionObjectList functionObjects_; mutable functionObjectList functionObjects_;
......
...@@ -131,11 +131,7 @@ bool Foam::functionEntries::codeStream::execute ...@@ -131,11 +131,7 @@ bool Foam::functionEntries::codeStream::execute
// see if library is loaded // see if library is loaded
void* lib = NULL; void* lib = NULL;
if if (isA<IOdictionary>(topDict(parentDict)))
(
isA<IOdictionary>(topDict(parentDict))
&& parentDict.dictName() != Time::controlDictName
)
{ {
lib = libs(parentDict).findLibrary(libPath); lib = libs(parentDict).findLibrary(libPath);
} }
...@@ -150,11 +146,7 @@ bool Foam::functionEntries::codeStream::execute ...@@ -150,11 +146,7 @@ bool Foam::functionEntries::codeStream::execute
// avoid compilation if possible by loading an existing library // avoid compilation if possible by loading an existing library
if (!lib) if (!lib)
{ {
if if (isA<IOdictionary>(topDict(parentDict)))
(
isA<IOdictionary>(topDict(parentDict))
&& parentDict.dictName() != Time::controlDictName
)
{ {
// Cached access to dl libs. Guarantees clean up upon destruction // Cached access to dl libs. Guarantees clean up upon destruction
// of Time. // of Time.
...@@ -223,11 +215,7 @@ bool Foam::functionEntries::codeStream::execute ...@@ -223,11 +215,7 @@ bool Foam::functionEntries::codeStream::execute
// all processes must wait for compile to finish // all processes must wait for compile to finish
reduce(create, orOp<bool>()); reduce(create, orOp<bool>());
if if (isA<IOdictionary>(topDict(parentDict)))
(
isA<IOdictionary>(topDict(parentDict))
&& parentDict.dictName() != Time::controlDictName
)
{ {
// Cached access to dl libs. Guarantees clean up upon destruction // Cached access to dl libs. Guarantees clean up upon destruction
// of Time. // of Time.
......
...@@ -25,6 +25,12 @@ License ...@@ -25,6 +25,12 @@ License
#include "dlLibraryTable.H" #include "dlLibraryTable.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "long.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::dlLibraryTable, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
...@@ -55,7 +61,11 @@ Foam::dlLibraryTable::~dlLibraryTable() ...@@ -55,7 +61,11 @@ Foam::dlLibraryTable::~dlLibraryTable()
// bug in dlclose - does not call static destructors of // bug in dlclose - does not call static destructors of
// loaded library when actually unloading the library. // loaded library when actually unloading the library.
// See https://bugzilla.novell.com/show_bug.cgi?id=680125 and 657627. // See https://bugzilla.novell.com/show_bug.cgi?id=680125 and 657627.
// Seems related to using a non-system compiler! if (debug)
{
Info<< "dlLibraryTable::~dlLibraryTable() : closing " << iter()
<< " with handle " << long(iter.key()) << endl;
}
dlClose(iter.key()); dlClose(iter.key());
} }
} }
...@@ -73,6 +83,12 @@ bool Foam::dlLibraryTable::open ...@@ -73,6 +83,12 @@ bool Foam::dlLibraryTable::open
{ {
void* functionLibPtr = dlOpen(functionLibName); void* functionLibPtr = dlOpen(functionLibName);
if (debug)
{
Info<< "dlLibraryTable::open : opened " << functionLibName
<< " resulting in handle " << long(functionLibPtr) << endl;
}
if (!functionLibPtr) if (!functionLibPtr)
{ {
if (verbose) if (verbose)
...@@ -107,6 +123,12 @@ bool Foam::dlLibraryTable::close ...@@ -107,6 +123,12 @@ bool Foam::dlLibraryTable::close
void* libPtr = findLibrary(functionLibName); void* libPtr = findLibrary(functionLibName);
if (libPtr) if (libPtr)
{ {
if (debug)
{
Info<< "dlLibraryTable::close : closing " << functionLibName
<< " with handle " << long(libPtr) << endl;
}
erase(libPtr); erase(libPtr);
if (!dlClose(libPtr)) if (!dlClose(libPtr))
......
...@@ -63,6 +63,9 @@ class dlLibraryTable ...@@ -63,6 +63,9 @@ class dlLibraryTable
public: public:
// Declare name of the class and its debug switch
ClassName("dlLibraryTable");
// Constructors // Constructors
//- Construct null //- Construct null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment