mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
fs: mqueue: Fix file_mq_open() for SMP
Summary: - I noticed that sometimes mqueue_test in ostest failed (i.e. mq_open failed) with rv-virt:smp. - This commit fixes this issue by replacing sched_lock with critical section. Impact: - file_mq_open() Testing: - Tested with ostest on QEMU-7.1 Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
committed by
Xiang Xiao
parent
b1773934fe
commit
e6884b8cb1
+7
-5
@@ -162,6 +162,7 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name,
|
|||||||
FAR struct mq_attr *attr = NULL;
|
FAR struct mq_attr *attr = NULL;
|
||||||
struct inode_search_s desc;
|
struct inode_search_s desc;
|
||||||
char fullpath[MAX_MQUEUE_PATH];
|
char fullpath[MAX_MQUEUE_PATH];
|
||||||
|
irqstate_t flags;
|
||||||
mode_t mode = 0;
|
mode_t mode = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -210,11 +211,12 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name,
|
|||||||
|
|
||||||
/* Make sure that the check for the existence of the message queue
|
/* Make sure that the check for the existence of the message queue
|
||||||
* and the creation of the message queue are atomic with respect to
|
* and the creation of the message queue are atomic with respect to
|
||||||
* other processes executing mq_open(). A simple sched_lock() should
|
* other processes executing mq_open(). A simple sched_lock() would
|
||||||
* be sufficient.
|
* be sufficient for non-SMP case but critical section is needed for
|
||||||
|
* SMP case.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sched_lock();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the inode for this mqueue. This should succeed if the message
|
/* Get the inode for this mqueue. This should succeed if the message
|
||||||
* queue has already been created. In this case, inode_find() will
|
* queue has already been created. In this case, inode_find() will
|
||||||
@@ -322,7 +324,7 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
RELEASE_SEARCH(&desc);
|
RELEASE_SEARCH(&desc);
|
||||||
sched_unlock();
|
leave_critical_section(flags);
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_inode:
|
errout_with_inode:
|
||||||
@@ -330,7 +332,7 @@ errout_with_inode:
|
|||||||
|
|
||||||
errout_with_lock:
|
errout_with_lock:
|
||||||
RELEASE_SEARCH(&desc);
|
RELEASE_SEARCH(&desc);
|
||||||
sched_unlock();
|
leave_critical_section(flags);
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user