Skip to content

Bug: Data races on shared conn/reader; GUI transfer blocks the message loop and cannot be cancelled #22

Open

Description

@LinuxSuRen

Description

Sender side (pkg/sender.go):

  • the "connection refused" branch (around line 125) re-assigns the shared conn variable and re-dials while the background resend goroutine (started around line 96) still uses the old conn and the same bufio.Reader — unsynchronized read/write on conn and concurrent use of one bufio.Reader. Running with -race will flag this.

GUI side (ui/main.go):

  • the wait case runs waiter.Start(msg) synchronously inside w.OnMessage(...) — the message handler blocks until the whole transfer finishes, so the window cannot process any further messages meanwhile,
  • stopWait is explicitly unimplemented (fmt.Println("not support stop wait")), so a running receive/send cannot be cancelled from the UI at all.

Suggested fix

  • give each goroutine its own conn/reader, or guard them with a mutex; re-create the bufio.Reader after Seek (or use f.ReadAt, which needs no reader state),
  • run transfers in their own goroutine with a context.Context; implement stopWait by cancelling that context.

Environment: master@a4ebe30.

Activity

  1. added
    bug
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions