Improve code structure#3
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note 🎁 Summarized by CodeRabbit FreeYour organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above. Comment |
- Fix #2: Guard buffer mutex release after crash with a volatile flag (holding_buffer_mutex) to avoid undefined behavior when unlocking a mutex not owned by the calling thread - Fix #3: Reset plc_crash_signal to 0 at the start of plc_cycle_thread so stale values don't persist after successful recovery - Fix #4: Add plc_force_error_state() function for the watchdog to transition to ERROR state through the mutex instead of writing plc_state directly. Remove extern PLCState from watchdog.c - Fix #5: Skip watchdog heartbeat check when already in ERROR state to prevent repeated error log spam every 2 seconds. Move heartbeat reset to the non-RUNNING branch so it happens once on ERROR entry - Fix #6: Add trailing newline to plc_state_manager.h - Fix #8: Add threading.Lock to protect _crash_times and _safe_mode in RuntimeManager against concurrent access from the monitor and compilation threads - Fix #9: Rename _should_enter_safe_mode to _record_crash_and_check_safe_mode to make the side effect explicit Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This PR fixes many issues in the runtime source code such as: