Skip to content

re add tokio pipes, but fetch sequentially#170

Open
wiiznokes wants to merge 2 commits intomasterfrom
fix-blocking-runtime
Open

re add tokio pipes, but fetch sequentially#170
wiiznokes wants to merge 2 commits intomasterfrom
fix-blocking-runtime

Conversation

@wiiznokes
Copy link
Copy Markdown
Collaborator

Please explain briefly what the PR does.

@GonzRon
Copy link
Copy Markdown

GonzRon commented Feb 6, 2026

Please explain briefly what the PR does.

I looked into it because I switched to clipboard-manager from copyq on Cosmic desktop.

● This PR directly addresses the exact class of bug that was crashing your system. Here's what it does:

PR #170: "re add tokio pipes, but fetch sequentially"

Problem it fixes: When reading clipboard data from Wayland pipes, the old code used blocking synchronous std::io::pipe reads (pipe.read_to_end()). If the source app was slow or unresponsive, this would block indefinitely, hanging the clipboard watcher.

What it changes (3 files, +29/-52 lines):

  1. clipboard_watcher.rs — Switches from std::io::pipe() (blocking) to tokio::net::unix::pipe::pipe() (async). This means pipe reads are non-blocking and can be cancelled.
    Also cleans up the SeatData struct by using mem::replace instead of take-then-assign, and removes an unused events: Vec field that was accumulating data offer events
    without being consumed.
  2. clipboard.rs — Wraps each pipe read in a 500ms timeout (tokio::time::timeout(Duration::from_millis(500), pipe.read_to_end(...))). If a clipboard source doesn't deliver
    data within 500ms, it logs a warning and moves on instead of blocking forever. The reads are also now async (AsyncReadExt instead of std::io::Read).
  3. .gitignore — Adds the db lock file.

In short: This is exactly the kind of fix CopyQ is missing — it prevents clipboard pipe reads from blocking indefinitely by using async I/O with a 500ms timeout, which prevents the process accumulation and resource exhaustion that was crashing your Electron apps via D-Bus FD exhaustion.

Lcstyle added a commit to Lcstyle/clipboard-manager that referenced this pull request Feb 6, 2026
- Add --toggle/-t CLI flag to toggle popup via keyboard shortcut
- Add --help/-h with setup instructions for COSMIC custom shortcuts
- Add file-based IPC (polling) for external toggle signaling
- Fix popup positioning: icon click uses XDG popup (anchored),
  --toggle uses centered layer surface
- Fix close_popup to correctly destroy layer surfaces vs XDG popups
- Switch clipboard pipe reads from blocking std::io to async tokio
  with 500ms timeout (based on PR cosmic-utils#170)
- Fix search input to support Enter-to-copy focused item
- Add db lock file to .gitignore

Incorporates and fixes issues from PR cosmic-utils#170 and PR cosmic-utils#160:
- Replaces notify-based file watcher with simple 250ms polling to
  prevent CPU busy-loop caused by inotify on busy /run/user/ dir
- Uses Anchor::empty() for centered popup instead of edge-anchored

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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