Skip to content

file: fix concurrent load/commit race condition - #24

Closed
JerryM-Quectel wants to merge 1 commit into
openwrt:masterfrom
JerryM-Quectel:master
Closed

file: fix concurrent load/commit race condition#24
JerryM-Quectel wants to merge 1 commit into
openwrt:masterfrom
JerryM-Quectel:master

Conversation

@JerryM-Quectel

Copy link
Copy Markdown

Root cause
With blocking LOCK_SH, a reader could open an old inode first, then wait for the writer lock; after the writer renamed and unlocked, the reader still operated on that stale inode, causing stale reads or lost updates under contention.

Solution
Changed the read path to use non-blocking shared lock attempts and, on lock contention, close and reopen the file before retrying so it tracks the latest inode behind the path.

Root cause
With blocking LOCK_SH, a reader could open an old inode first,
then wait for the writer lock; after the writer renamed and
unlocked, the reader still operated on that stale inode, causing
stale reads or lost updates under contention.

Solution
Changed the read path to use non-blocking shared lock attempts and,
on lock contention, close and reopen the file before retrying
so it tracks the latest inode behind the path.

Signed-off-by: jerry.meng <jerry.meng@quectel.com>
@JerryM-Quectel

Copy link
Copy Markdown
Author

Close this PR, will resubmit via dedicated feature branch with proper Signed-off-by.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant