Skip to content

Commit

Permalink
capicxx-core-runtime 3.1.12.3
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent 45a3dea commit 2c259a9
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 52 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.3
- Added copy constructor for CommonAPI CallInfo

v3.1.12.2
- Defer Runtime destruction till shared object is unloaded

Expand Down
3 changes: 3 additions & 0 deletions include/CommonAPI/CallInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ struct COMMONAPI_EXPORT CallInfo {
CallInfo(Timeout_t _timeout, Sender_t _sender)
: timeout_(_timeout), sender_(_sender) {
}
CallInfo(const CallInfo &_other)
: timeout_(_other.timeout_), sender_(_other.sender_) {
}

Timeout_t timeout_;
Sender_t sender_;
Expand Down
104 changes: 52 additions & 52 deletions src/CommonAPI/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ std::shared_ptr<Runtime> Runtime::get() {
Runtime::Runtime()
: defaultBinding_(COMMONAPI_DEFAULT_BINDING),
defaultFolder_(COMMONAPI_DEFAULT_FOLDER),
isConfigured_(false),
isInitialized_(false) {
isConfigured_(false),
isInitialized_(false) {
}

Runtime::~Runtime() {
Expand All @@ -98,7 +98,7 @@ Runtime::registerFactory(const std::string &_binding, std::shared_ptr<Factory> _
}

if (isRegistered && isInitialized_)
_factory->init();
_factory->init();

return isRegistered;
}
Expand Down Expand Up @@ -152,20 +152,20 @@ void Runtime::init() {

void
Runtime::initFactories() {
std::lock_guard<std::mutex> itsLock(factoriesMutex_);
if (!isInitialized_) {
COMMONAPI_INFO("Loading configuration file \'", usedConfig_, "\'");
COMMONAPI_INFO("Using default binding \'", defaultBinding_, "\'");
COMMONAPI_INFO("Using default shared library folder \'", defaultFolder_, "\'");
std::lock_guard<std::mutex> itsLock(factoriesMutex_);
if (!isInitialized_) {
COMMONAPI_INFO("Loading configuration file \'", usedConfig_, "\'");
COMMONAPI_INFO("Using default binding \'", defaultBinding_, "\'");
COMMONAPI_INFO("Using default shared library folder \'", defaultFolder_, "\'");

if (defaultFactory_)
defaultFactory_->init();
if (defaultFactory_)
defaultFactory_->init();

for (auto f : factories_)
f.second->init();
for (auto f : factories_)
f.second->init();

isInitialized_ = true;
}
isInitialized_ = true;
}
}

bool
Expand All @@ -179,13 +179,13 @@ Runtime::readConfiguration() {
#else
if (getcwd(currentDirectory, MAX_PATH_LEN)) {
#endif
usedConfig_ = currentDirectory;
usedConfig_ += "/";
usedConfig_ += COMMONAPI_DEFAULT_CONFIG_FILE;
usedConfig_ = currentDirectory;
usedConfig_ += "/";
usedConfig_ += COMMONAPI_DEFAULT_CONFIG_FILE;

struct stat s;
if (stat(usedConfig_.c_str(), &s) != 0) {
usedConfig_ = defaultConfig_;
usedConfig_ = defaultConfig_;
if (stat(usedConfig_.c_str(), &s) != 0) {
tryLoadConfig = false;
}
Expand Down Expand Up @@ -249,9 +249,9 @@ std::shared_ptr<Proxy>
Runtime::createProxy(
const std::string &_domain, const std::string &_interface, const std::string &_instance,
const ConnectionId_t &_connectionId) {
if (!isInitialized_) {
initFactories();
}
if (!isInitialized_) {
initFactories();
}

// Check whether we already know how to create such proxies...
std::shared_ptr<Proxy> proxy = createProxyHelper(_domain, _interface, _instance, _connectionId, false);
Expand All @@ -270,9 +270,9 @@ std::shared_ptr<Proxy>
Runtime::createProxy(
const std::string &_domain, const std::string &_interface, const std::string &_instance,
std::shared_ptr<MainLoopContext> _context) {
if (!isInitialized_) {
initFactories();
}
if (!isInitialized_) {
initFactories();
}

// Check whether we already know how to create such proxies...
std::shared_ptr<Proxy> proxy = createProxyHelper(_domain, _interface, _instance, _context, false);
Expand All @@ -291,9 +291,9 @@ Runtime::createProxy(
bool
Runtime::registerStub(const std::string &_domain, const std::string &_interface, const std::string &_instance,
std::shared_ptr<StubBase> _stub, const ConnectionId_t &_connectionId) {
if (!isInitialized_) {
initFactories();
}
if (!isInitialized_) {
initFactories();
}

bool isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _connectionId, false);
if (!isRegistered) {
Expand All @@ -309,9 +309,9 @@ Runtime::registerStub(const std::string &_domain, const std::string &_interface,
bool
Runtime::registerStub(const std::string &_domain, const std::string &_interface, const std::string &_instance,
std::shared_ptr<StubBase> _stub, std::shared_ptr<MainLoopContext> _context) {
if (!isInitialized_) {
initFactories();
}
if (!isInitialized_) {
initFactories();
}

bool isRegistered = registerStubHelper(_domain, _interface, _instance, _stub, _context, false);
if (!isRegistered) {
Expand Down Expand Up @@ -382,28 +382,28 @@ Runtime::loadLibrary(const std::string &_library) {
}
#else
std::size_t soStart = itsLibrary.rfind(".so");
if (soStart == std::string::npos) {
// Library name does not contain ".so" --> add it
itsLibrary += ".so";
} else if (soStart < itsLibrary.length() - 3) {
// We found ".so" but even the last one is not the end
// of the filename
soStart += 3;

// Check the version information
while (soStart < itsLibrary.length()) {
if (itsLibrary[soStart] != '.'
&& !std::isdigit(static_cast<unsigned char>(itsLibrary[soStart]))) {
break;
}
soStart++;
}

// What should be a version is something else
// --> add another ".so"
if (soStart < itsLibrary.length())
itsLibrary += ".so";
}
if (soStart == std::string::npos) {
// Library name does not contain ".so" --> add it
itsLibrary += ".so";
} else if (soStart < itsLibrary.length() - 3) {
// We found ".so" but even the last one is not the end
// of the filename
soStart += 3;

// Check the version information
while (soStart < itsLibrary.length()) {
if (itsLibrary[soStart] != '.'
&& !std::isdigit(static_cast<unsigned char>(itsLibrary[soStart]))) {
break;
}
soStart++;
}

// What should be a version is something else
// --> add another ".so"
if (soStart < itsLibrary.length())
itsLibrary += ".so";
}
#endif

bool isLoaded(true);
Expand Down

0 comments on commit 2c259a9

Please sign in to comment.