Skip to content

Serialize folder monitor state#7

Open
sickn33 wants to merge 1 commit into
chenyuxiaojin:mainfrom
sickn33:audit-folder-monitor-lifecycle
Open

Serialize folder monitor state#7
sickn33 wants to merge 1 commit into
chenyuxiaojin:mainfrom
sickn33:audit-folder-monitor-lifecycle

Conversation

@sickn33

@sickn33 sickn33 commented Jun 29, 2026

Copy link
Copy Markdown

Summary

  • serialize FolderMonitor start/stop state mutations on its private queue
  • make isMonitoring read the same queue-owned state
  • capture the file descriptor owned by each dispatch source so a rapid stop/start cannot close the new descriptor from an old cancel handler
  • add a start/stop state test

Why

FolderMonitor handled file-system events on a private queue, but public start/stop mutated source, watchedURL, knownFiles, and generation from the caller thread. That leaves room for races between delayed filesystem scans and settings changes. The old cancel handler also read self.fileDescriptor, which can point to a newer descriptor if monitoring is restarted before the old source finishes cancelling.

Verification

  • git diff --check
  • xcodebuild test -project DropKit/DropKit.xcodeproj -scheme DropKit -destination 'platform=macOS' -derivedDataPath /private/tmp/dropkit-foldermonitor-derived CODE_SIGNING_ALLOWED=NO passed 12 tests, 0 failures

@sickn33 sickn33 force-pushed the audit-folder-monitor-lifecycle branch from 6301cb7 to 07246d6 Compare June 29, 2026 15:47
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.

2 participants