fix client deadlock on server death during writes

Fixes #234

Similar to #181 (which was about read methods), the client deadlocks on
server drop on write methods (Write/ReadFrom). This is another case of
broadcastErr() and dispatchRequest() deadlocking.

The fix is to bump up the channel used to communicate about inflight
packets to maxConcurrentRequests+1 (+1 is new). It seems that it can
have the full set of packets going and hit the error (triggering
broadcastErr) yet it still tries to call dispatchRequest again. More
details in that ticket.

I'm also bumping up the chan buffer in the read methods to keep them
consistent. I can't reproduce the problem, but it looks like it should
have it. So it might just be a much harder race to trigger.

This also includes 2 tests which reprocuded the issue for ReadFrom and

Change-Id: Icb6cefc682da28b8bd495cc8fddd65b9a37eb448
2 files changed
tree: b3cc498d91689afc5fbd960bf91f0e83329cec6c
  1. .gitignore
  2. .travis.yml
  6. attrs.go
  7. attrs_stubs.go
  8. attrs_test.go
  9. attrs_unix.go
  10. client.go
  11. client_integration_darwin_test.go
  12. client_integration_linux_test.go
  13. client_integration_test.go
  14. client_test.go
  15. conn.go
  16. debug.go
  17. example_test.go
  18. examples/
  19. match.go
  20. other_test.go
  21. packet-manager.go
  22. packet-manager_go1.8.go
  23. packet-manager_legacy.go
  24. packet-manager_test.go
  25. packet-typing.go
  26. packet.go
  27. packet_test.go
  28. release.go
  29. request-example.go
  30. request-interfaces.go
  32. request-server.go
  33. request-server_test.go
  34. request-unix.go
  35. request.go
  36. request_test.go
  37. request_windows.go
  38. server.go
  39. server_integration_test.go
  40. server_standalone/
  41. server_statvfs_darwin.go
  42. server_statvfs_impl.go
  43. server_statvfs_linux.go
  44. server_statvfs_stubs.go
  45. server_stubs.go
  46. server_test.go
  47. server_unix.go
  48. sftp.go


The sftp package provides support for file system operations on remote ssh servers using the SFTP subsystem. It also implements an SFTP server for serving files from the filesystem.

UNIX Build Status GoDoc

usage and examples

See for examples and usage.

The basic operation of the package mirrors the facilities of the os package.

The Walker interface for directory traversal is heavily inspired by Keith Rarick's fs package.


  • There is way too much duplication in the Client methods. If there was an unmarshal(interface{}) method this would reduce a heap of the duplication.


We welcome pull requests, bug fixes and issue reports.

Before proposing a large change, first please discuss your change by raising an issue.

For API/code bugs, please include a small, self contained code example to reproduce the issue. For pull requests, remember test coverage.

We try to handle issues and pull requests with a 0 open philosophy. That means we will try to address the submission as soon as possible and will work toward a resolution. If progress can no longer be made (eg. unreproducible bug) or stops (eg. unresponsive submitter), we will close the bug.