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


##########
libminifi/src/FlowController.cpp:
##########
@@ -150,6 +154,7 @@ bool FlowController::applyConfiguration(const std::string 
&source, const std::st
     this->root_ = std::move(prevRoot);

Review Comment:
   we should restructure this method to avoid manual locking, the whole lock 
protected region could get its own block, we should move the logging block out 
of the try block to the very end of this method
   
   ```
     updating_ = true;
   
     {
       std::lock_guard<std::recursive_mutex> flow_lock(mutex_);
       stop();
       unload();
       controller_map_->clear();
       clearResponseNodes();
       if (metrics_publisher_) {
         metrics_publisher_->clearMetricNodes();
       }
       auto prevRoot = std::move(this->root_);
       this->root_ = std::move(newRoot);
       processor_to_controller_.clear();
       initialized_ = false;
       bool started = false;
       try {
         load(std::move(root_), true);
         flow_update_ = true;
         started = start() == 0;
       } catch (...) {
         this->root_ = std::move(prevRoot);
         load(std::move(this->root_), true);
         flow_update_ = true;
       }
     }
   
     updating_ = false;
   
     if (started) {
       auto flowVersion = flow_configuration_->getFlowVersion();
       if (flowVersion) {
         logger_->log_debug("Setting flow id to %s", flowVersion->getFlowId());
         configuration_->set(Configure::nifi_c2_flow_id, 
flowVersion->getFlowId());
         configuration_->set(Configure::nifi_c2_flow_url, 
flowVersion->getFlowIdentifier()->getRegistryUrl());
       } else {
         logger_->log_debug("Invalid flow version, not setting");
       }
     }
   
     return started;
   ```



-- 
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