lordgamez commented on code in PR #1568: URL: https://github.com/apache/nifi-minifi-cpp/pull/1568#discussion_r1187591401
########## libminifi/src/FlowController.cpp: ########## @@ -127,35 +127,34 @@ bool FlowController::applyConfiguration(const std::string &source, const std::st logger_->log_info("Starting to reload Flow Controller with flow control name %s, version %d", newRoot->getName(), newRoot->getVersion()); - updating_.beginUpdate(); bool started = false; - { - std::lock_guard<std::recursive_mutex> flow_lock(mutex_); - stop(); - - root_wrapper_.setNewRoot(std::move(newRoot)); - initialized_ = false; - try { - load(true); - started = start() == 0; - } catch (const std::exception& ex) { - logger_->log_error("Caught exception while starting flow, type %s, what: %s", typeid(ex).name(), ex.what()); - } catch (...) { - logger_->log_error("Caught unknown exception while starting flow, type %s", getCurrentExceptionTypeName()); - } - if (!started) { - logger_->log_error("Failed to start new flow, restarting previous flow"); - root_wrapper_.restoreBackup(); - load(true); - start(); - } else { - root_wrapper_.clearBackup(); + auto update_lock = updating_.getUpdateLock(); + { + std::lock_guard<std::recursive_mutex> flow_lock(mutex_); Review Comment: Updated in 1fd1685fbccb60386133baeee87ddcffa4747487 ########## libminifi/include/FlowController.h: ########## @@ -149,6 +149,34 @@ class FlowController : public core::controller::ForwardingControllerServiceProvi std::map<std::string, std::unique_ptr<io::InputStream>> getDebugInfo() override; private: + class UpdateState { + class UpdateLock; + public: + UpdateLock getUpdateLock() { return UpdateLock(*this); } + bool isUpdating() const { return update_block_count_ > 0; } + + private: + class UpdateLock { + public: + UpdateLock(UpdateState& update_state) : update_state_(update_state) { + update_state_.beginUpdate(); + } + + ~UpdateLock() { + update_state_.endUpdate(); + } + private: + UpdateState& update_state_; + }; + Review Comment: The latter sounds good, thanks, updated in 1fd1685fbccb60386133baeee87ddcffa4747487 -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org