Skip to content

fix named_mutex to open file descriptors lazily - #14861

Merged
remibettan merged 3 commits into
realsenseai:developmentfrom
remibettan:linux_backend_dev_video_change_hw_reset_fix
Mar 31, 2026
Merged

remibettan merged 3 commits into
realsenseai:developmentfrom
remibettan:linux_backend_dev_video_change_hw_reset_fix

Conversation

@remibettan

Copy link
Copy Markdown
Contributor

Tracked by: RSDSO-20602

Copilot AI review requested due to automatic review settings March 24, 2026 16:48
Comment thread src/linux/backend-v4l2.cpp Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the Linux V4L2 named_mutex implementation to avoid holding an open device file descriptor for the lifetime of the mutex object by opening it lazily on first lock()/try_lock() and closing it on final unlock(). This is intended to reduce issues around hardware resets while the process is running (RSDSO-20602).

Changes:

  • Initialize named_mutex::_fildes to -1 and defer open() until the first lock acquisition.
  • Close the FD on the last unlock() and guard destructor close() behind _fildes >= 0.
  • Add lazy-open logic to both lock() and try_lock().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/linux/backend-v4l2.cpp Resolved
Comment thread src/linux/backend-v4l2.cpp Resolved
Comment thread src/linux/backend-v4l2.cpp Resolved
@Nir-Az
Nir-Az requested a review from OhadMeir March 24, 2026 21:36

@OhadMeir OhadMeir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

@remibettan
remibettan force-pushed the linux_backend_dev_video_change_hw_reset_fix branch from 020a8e0 to 3ef6717 Compare March 29, 2026 13:45
Comment thread src/linux/backend-v4l2.cpp Resolved
@remibettan
remibettan force-pushed the linux_backend_dev_video_change_hw_reset_fix branch from 3ef6717 to 8e5c5ea Compare March 30, 2026 10:43
@remibettan
remibettan merged commit 69b7d8b into realsenseai:development Mar 31, 2026
27 checks passed
@remibettan
remibettan deleted the linux_backend_dev_video_change_hw_reset_fix branch July 8, 2026 12:05
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.

4 participants