fgerlits commented on code in PR #2292:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2292#discussion_r4425752788


##########
minifi_main/MiNiFiMain.cpp:
##########
@@ -290,7 +291,24 @@ int main(int argc, char **argv) {
   process_running.test_and_set();
 
   std::atomic<bool> restart_token{false};
-  const auto request_restart = [&] {
+  std::atomic<int32_t> exit_code{0};
+  std::mutex shutdown_request_mutex;
+  bool shutdown_requested = false;

Review Comment:
   This mixing of atomics and a mutex looks messy; could we merge the two 
actions into a single 3-valued atomic 
(initial_state/restart_requested/shutdown_requested) to simplify the logic?



##########
libminifi/src/c2/C2Agent.cpp:
##########
@@ -179,6 +200,17 @@ void C2Agent::configure(const std::shared_ptr<Configure> 
&configure, bool reconf
   }
   logger_->log_debug("Using {} as the heartbeat period", heart_beat_period_);
 
+  c2_connection_timeout_ = parseTimeoutPeriod(configuration_, 
std::string{Configuration::nifi_c2_connection_timeout}, logger_);
+  if (c2_connection_timeout_ && *c2_connection_timeout_ <= heart_beat_period_) 
{
+    logger_->log_warn(
+        "C2 connection timeout is less than the heartbeat period: c2 
connection timeout={}, heartbeat period={}. Adjusting it to be twice the "
+        "heartbeat period",
+        *c2_connection_timeout_,
+        heart_beat_period_);
+    c2_connection_timeout_ = heart_beat_period_ * 2;
+    logger_->log_debug("Using {} as the C2 connection timeout", 
*c2_connection_timeout_);
+  }

Review Comment:
   This `configured value -> effective connection timeout value` function is 
quite strange:
   <img width="500" height="250" alt="Image" 
src="https://github.com/user-attachments/assets/bc150b4f-ab09-4647-af2c-63c7130201dd";
 />
   I don't mind it if you think it's useful to have it like this, but I think 
an `effective connection timeout value = max(configured value, 2 * heartbeat 
period) [if configured value > 0]` logic would be easier to understand.



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