Repository navigation
feat: drive lock and gui preferences - #81
Open
RevokeTime wants to merge 2 commits into
Open
RevokeTime wants to merge 2 commits into
RevokeTime wants to merge 2 commits into
Conversation
…event interference
Implement multi-tier optical drive locking to protect active test runs
(ERRC, JB, FE/TE, RT, WT) against external interference from physical
tray button presses, background filesystem activity, and other processes:
1. Transport & MMC Layer (lib/qpxtransport):
- Add lock_device() / unlock_device() to Scsi_Command across all platforms.
- Linux: apply flock(fd, LOCK_EX | LOCK_NB) to inhibit udisks2 media
change polling (GESN/TUR) and desktop automounting, and CDROM_LOCKDOOR ioctl.
- Windows: issue FSCTL_LOCK_VOLUME / FSCTL_DISMOUNT_VOLUME to isolate
volume filesystem access, and IOCTL_CDROM_EXCLUSIVE_ACCESS with
ExclusiveAccessLockDevice to obtain cdrom.sys driver exclusive access.
- Implement lock_drive(drive_info*) and unlock_drive(drive_info*) combining
OS exclusive locks with SCSI MMC SPC_PREVENT_ALLOW_MEDIUM_REMOVAL (1/0).
- Add automatic unlock fallback in drive_info::~drive_info() to prevent deadlocks.
2. Scan Engine (lib/qpxscan):
- Wrap qscanner::run() with lock_drive() upon test startup and unlock_drive()
upon test completion or abort.
- Add safety fallback unlock in qscanner::~qscanner() if still locked.
- Support toggling via set_lock_drive(bool) / is_lock_drive_enabled().
3. CLI (console/qscan):
- Enable optical drive locking by default during tests.
- Add --no-lock command line option to allow opting out.
4. GUI (gui):
- Add lock_drive boolean option to QPxSettings (persisted under /devices).
- Add "Lock drive during scan tests (prevent external interference)"
checkbox in Preferences -> Devices.
- Propagate lock_drive setting from mainwindow into device and pass
--no-lock to qscan child process when locking is disabled.
…ests safely
Implement graceful stop and emergency hardware unlock mechanisms in the GUI
to prevent the optical drive from remaining locked when tests hang or when
the user forcefully closes the application window:
1. Emergency Hardware Unlock (gui/device):
- Add force_unlock() to issue synchronous MMC PREVENT_ALLOW_MEDIUM_REMOVAL (0)
hardware commands directly to the optical drive.
- Add force_stop_and_unlock(timeout_ms) which prioritizes graceful process
termination (proc->terminate() / Windows stop event), waits up to timeout_ms,
force-kills hung child processes if unresponsive, and executes force_unlock().
- Add repeat-stop force kill to stop_tests(): double-clicking the Stop button
while a test is hanging immediately escalates to proc->kill() and unlocks.
- Invoke force_stop_and_unlock() in device::~device() for clean teardown.
2. Window Close Interception (gui/mainwindow):
- Override closeEvent() to detect active scan tests on any device.
- Display a confirmation dialog warning the user that tests will be aborted
and the drive unlocked.
- On confirmation, trigger force_stop_and_unlock() across all active devices
before exiting cleanly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lock the drive when starting the scan to prevent external processes from interfering with it; this also helps mitigate the issue described in #76, making the scanning process more stable.