[Grbl_Esp32 PR#740] fix race with sys_rt_exec_state by breaking out bools – v2

未分类 bolang 6个月前 (10-14) 61次浏览

Issue #740 | 状态: 进行中 | 作者: treib | 创建时间: 2021-01-17


A simple fix for the race condition with sysrtexec_state that breaks out all the state bits into separate bools.

A few notes:

– I renamed the cycle_stop global that was broken out previously to be consistent with the newly-added bits.

– In the existing code, in three places (the main protocolexecrtsystem() as well as the limit check loops in Limits.cpp and CoreXY.cpp) the ExecState is captured into a local copy which is then used in the if/else logic. To keep the functionality and structure the same, I made a sysgetrtexec_state() call in System.cpp that pulls all the global bools back into a bitfield for this purpose. This all should be functionally the same as before.

Note that sysgetrtexecstate() includes the cycle_stop bit as it used to in the olden days, and I changed the if/else to check it that way for consistency. (This may make line 275 in Protocol.cpp look like a mistake at first glance, but it should be correct.)

– Previously there was some discussion on whether sysgetrtexecstate() and the ExecState bitfield are necessary, but I feel it is a clean way to snapshot the current state in protocolexecrt_system() for the if/else logic to generate the next state.

原始Issue: https://github.com/bdring/Grbl_Esp32/pull/740

喜欢 (0)