Skip to content

fix(smb): close smb sessions during transfers#2579

Open
shoyuf wants to merge 1 commit into
OpenListTeam:mainfrom
maybeLab:fix/smb-session-lifecycle
Open

fix(smb): close smb sessions during transfers#2579
shoyuf wants to merge 1 commit into
OpenListTeam:mainfrom
maybeLab:fix/smb-session-lifecycle

Conversation

@shoyuf
Copy link
Copy Markdown

@shoyuf shoyuf commented Jun 4, 2026

Summary / 摘要

Fix SMB session lifecycle handling during long transfers.

  • Store the *smb2.Session in the SMB driver so cleanup can call Session.Logoff(), not only Share.Umount().

  • Add connection leases around SMB operations so idle refresh does not replace a session while a file stream, upload, or same-storage copy is still active.

  • Keep the SMB download lease alive until the returned Link stream is closed.

  • Log off partially initialized sessions if Mount fails after Dial succeeds.

  • This PR has breaking changes.

  • This PR changes public API, config, storage format, or migration behavior.

  • This PR requires corresponding changes in related repositories.

Related repository PRs:

  • OpenList-Frontend:
  • OpenList-Docs:

Related Issues / 关联 Issue

Fixes #2578
Related to #2228

Testing / 测试

  • gofmt drivers/smb/driver.go drivers/smb/util.go
  • GOCACHE=/private/tmp/openlist-go-build-cache GOMODCACHE=/private/tmp/openlist-go-mod-cache GOPROXY=https://goproxy.cn,direct go test ./drivers/smb
  • go test ./...
  • Manual test / 手动测试:

go test ./... was attempted, but unrelated existing packages fail:

  • multiple drivers/offline packages fail on Go vet non-constant format string diagnostics;
  • pkg/aria2/rpc expects a local aria2 RPC server at localhost:6800.

The SMB package itself compiles successfully.

Checklist / 检查清单

  • I have read CONTRIBUTING.
  • I confirm this contribution follows the repository license, contribution policy, and code of conduct.
  • I have formatted the changed code with gofmt.
  • I have requested review from relevant maintainers or code owners where applicable.

AI Disclosure / AI 使用声明

  • This PR includes AI-assisted content.

Tools used / 使用工具:

  • ChatGPT
  • Codex
  • GitHub Copilot
  • Claude
  • Gemini
  • Other:

Usage scope / 使用范围:

  • Code generation / 代码生成

  • Refactoring / 重构

  • Documentation / 文档

  • Tests / 测试

  • Review assistance / 审查辅助

  • I have reviewed and validated all AI-assisted content included in this PR.

  • I have ensured that all AI-assisted commits include Co-Authored-By attribution.

  • I can reproduce all AI-assisted content included in this PR without any AI tools.

Co-authored-by: Codex <codex@openai.com>
Signed-off-by: shoyuf <shoyuf@shoyuf.top>
@shoyuf shoyuf force-pushed the fix/smb-session-lifecycle branch from 117c61c to ce34736 Compare June 4, 2026 07:11
@shoyuf shoyuf marked this pull request as ready for review June 4, 2026 07:13
Comment thread .github/workflows/test_image.yml Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't commit this file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Don't commit this file.

sorry, I forgot this

@shoyuf shoyuf force-pushed the fix/smb-session-lifecycle branch from fdc6f0a to ce34736 Compare June 4, 2026 12:10
@shoyuf shoyuf requested a review from xrgzs June 4, 2026 12:12
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.

[BUG] SMB sessions leak during long transfers until Windows connection limit is reached

2 participants