Add chicken bit to control CheckCaches periodic/post-command flags
This commit is contained in:
@@ -892,7 +892,9 @@ bool DoCommandPEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd, C
|
|||||||
AppendCommandLogEntry(res, tile, p1, p2, p3, cmd, log_flags);
|
AppendCommandLogEntry(res, tile, p1, p2, p3, cmd, log_flags);
|
||||||
|
|
||||||
if (unlikely(HasChickenBit(DCBF_DESYNC_CHECK_POST_COMMAND)) && !(GetCommandFlags(cmd) & CMD_LOG_AUX)) {
|
if (unlikely(HasChickenBit(DCBF_DESYNC_CHECK_POST_COMMAND)) && !(GetCommandFlags(cmd) & CMD_LOG_AUX)) {
|
||||||
CheckCaches(true, nullptr, CHECK_CACHE_INFRA_TOTALS);
|
CheckCachesFlags flags = CHECK_CACHE_ALL | CHECK_CACHE_EMIT_LOG;
|
||||||
|
if (HasChickenBit(DCBF_DESYNC_CHECK_NO_GENERAL)) flags &= ~CHECK_CACHE_GENERAL;
|
||||||
|
CheckCaches(true, nullptr, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.Failed()) {
|
if (res.Failed()) {
|
||||||
@@ -936,7 +938,9 @@ CommandCost DoCommandPScript(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, ui
|
|||||||
AppendCommandLogEntry(res, tile, p1, p2, p3, cmd, log_flags);
|
AppendCommandLogEntry(res, tile, p1, p2, p3, cmd, log_flags);
|
||||||
|
|
||||||
if (unlikely(HasChickenBit(DCBF_DESYNC_CHECK_POST_COMMAND)) && !(GetCommandFlags(cmd) & CMD_LOG_AUX)) {
|
if (unlikely(HasChickenBit(DCBF_DESYNC_CHECK_POST_COMMAND)) && !(GetCommandFlags(cmd) & CMD_LOG_AUX)) {
|
||||||
CheckCaches(true, nullptr, CHECK_CACHE_INFRA_TOTALS);
|
CheckCachesFlags flags = CHECK_CACHE_ALL | CHECK_CACHE_EMIT_LOG;
|
||||||
|
if (HasChickenBit(DCBF_DESYNC_CHECK_NO_GENERAL)) flags &= ~CHECK_CACHE_GENERAL;
|
||||||
|
CheckCaches(true, nullptr, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@@ -18,6 +18,7 @@ enum ChickenBitFlags {
|
|||||||
DCBF_MP_NO_STATE_CSUM_CHECK = 1,
|
DCBF_MP_NO_STATE_CSUM_CHECK = 1,
|
||||||
DCBF_DESYNC_CHECK_PERIODIC = 2,
|
DCBF_DESYNC_CHECK_PERIODIC = 2,
|
||||||
DCBF_DESYNC_CHECK_POST_COMMAND = 3,
|
DCBF_DESYNC_CHECK_POST_COMMAND = 3,
|
||||||
|
DCBF_DESYNC_CHECK_NO_GENERAL = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool HasChickenBit(ChickenBitFlags flag)
|
inline bool HasChickenBit(ChickenBitFlags flag)
|
||||||
|
@@ -1364,7 +1364,10 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
|
|||||||
if (!force_check) {
|
if (!force_check) {
|
||||||
int desync_level = _debug_desync_level;
|
int desync_level = _debug_desync_level;
|
||||||
|
|
||||||
if (unlikely(HasChickenBit(DCBF_DESYNC_CHECK_PERIODIC)) && desync_level < 1) desync_level = 1;
|
if (unlikely(HasChickenBit(DCBF_DESYNC_CHECK_PERIODIC)) && desync_level < 1) {
|
||||||
|
desync_level = 1;
|
||||||
|
if (HasChickenBit(DCBF_DESYNC_CHECK_NO_GENERAL)) flags &= ~CHECK_CACHE_GENERAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return here so it is easy to add checks that are run
|
/* Return here so it is easy to add checks that are run
|
||||||
* always to aid testing of caches. */
|
* always to aid testing of caches. */
|
||||||
|
Reference in New Issue
Block a user