adamdebreceni commented on code in PR #2056:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2056#discussion_r2481598278


##########
libminifi/src/core/extension/Extension.cpp:
##########
@@ -78,18 +78,38 @@ bool DynamicLibrary::unload() {
   return true;
 }
 
-void* DynamicLibrary::findSymbol(const char *name) {
+void* Extension::findSymbol(const char *name) {
   if (!handle_) {
     throw std::logic_error("Dynamic library has not been loaded");
   }
   return dlsym(handle_, name);
 }
 
-DynamicLibrary::~DynamicLibrary() = default;
+Extension::~Extension() {
+  if (info_ && info_->deinit) {
+    info_->deinit(info_->user_data);
+  }
+  unload();
+}
+
+bool Extension::initialize(const std::shared_ptr<minifi::Configure>& 
configure) {
+  logger_->log_trace("Initializing extension '{}'", name_);
+  if (void* init = findSymbol("InitExtension")) {
+    logger_->log_error("Found custom initializer for '{}'", name_);
+    
info_.reset(reinterpret_cast<Info*>(reinterpret_cast<MinifiExtension*(*)(MinifiConfig*)>(init)(reinterpret_cast<MinifiConfig*>(configure.get()))));
+    if (!info_) {
+      logger_->log_error("Failed to initialize extension '{}'", name_);

Review Comment:
   I think we should keep it as error, the user should investigate this and 
remove the extension if they don't actually need it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to