mirror of
https://github.com/SCST-project/scst.git
synced 2026-10-22 06:02:33 +00:00
scst_user: Protect the shared debug freeze flag with its mutex
DEBUG_TM_IGNORE_ALL workers share a freeze flag without synchronization. Manual review of the volatile warning confirmed that volatile does not protect these concurrent accesses. Store and snapshot the flag under the existing per-device mutex, then unlock before the intentional infinite sleep. The mutex is initialized before worker creation and destroyed after joins. Checkpatch reports VOLATILE: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst
This commit is contained in:
+6
-1
@@ -812,11 +812,16 @@ void *main_loop(void *arg)
|
||||
|
||||
while(1) {
|
||||
#ifdef DEBUG_TM_IGNORE_ALL
|
||||
int ignore_all;
|
||||
|
||||
pthread_mutex_lock(&dev->dev_mutex);
|
||||
if (dev->debug_tm_ignore && (random() % 50000) == 55) {
|
||||
TRACE_MGMT_DBG("%s", "Ignore ALL");
|
||||
dev->debug_tm_ignore_all = 1;
|
||||
}
|
||||
if (dev->debug_tm_ignore_all) {
|
||||
ignore_all = dev->debug_tm_ignore_all;
|
||||
pthread_mutex_unlock(&dev->dev_mutex);
|
||||
if (ignore_all) {
|
||||
/* Go Astral */
|
||||
while(1) {
|
||||
sleep(60);
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ struct vdisk_dev {
|
||||
#if defined(DEBUG_TM_IGNORE) || defined(DEBUG_TM_IGNORE_ALL)
|
||||
unsigned int debug_tm_ignore:1;
|
||||
#if defined(DEBUG_TM_IGNORE_ALL)
|
||||
volatile int debug_tm_ignore_all;
|
||||
int debug_tm_ignore_all;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user