Skip to content

Race condition / Concurrency problem on Fileread? #195

@sandreas

Description

@sandreas

Hey,

i noticed a strange behavior of my sftp server when downloading files: At random intervals the Download gets "-stalled-" and the server blocks one download permanently. Most of the time this happens with bigger files (>1MB), but sometimes smaller files run into that error, too. It seems to be completely random...

It also happens on Windows and MacOS at random progress (5%, 90%, event 100%), so OS seems to be irrelevant, but just for the sake of completeness my system specs:

MacBook Pro Early 2015, MacOS Sierra 10.12.6

Can someone reproduce this?
What could be the problem?

stalled

Code Sample:
https://github.com/sandreas/sftp/tree/race-condition/examples/request-server-simple

To get the sample:

git clone https://github.com/sandreas/sftp
cd sftp/
git checkout race-condition

# run sftp server, provide the files in /path/with/files via sftp on port 2022
# use a directory with at least 5 files and a few subdirectories
go run examples/request-server-simple/main.go --base-path="/path/with/files"

Now sftp is used in another Terminal:

# user: test, password: test
sftp -P 2022 test@localhost # password: test

# get all contents of the sftp, first time often works as expected
get -r *
# again, may work
get -r *
# ... try again, till suddenly one of the file downloads gets stalled (see attached screenshot)
get -r *

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions