Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Request mutex usage #455

Merged
merged 3 commits into from
Aug 3, 2021
Merged

Conversation

puellanivis
Copy link
Collaborator

As I was working on the filexfer PR again, I noticed some use of mutex-protected values outside of holding a mutex, and then not only do all the copies point to the same mutex, but also, because this mutex has to be set, the use of &sftp.Request{} will always generate an invalid structure that will panic.

I realize the pointer to mutex was there so that *r2 = *r would work and not generate an error during go vet that a mutex is being copied, but this design unfortunately creates even more issues than it solved. I tried a bunch of different ways to keep the pointer, but still have &sftp.Request{} not immediately be incurably invalid, but any solutions to this also require a mutex, which is the very problem we’re trying to avoid. We’re then stuck with having to copy values around the mutex. 🙁 A redesign might be necessary to avoid all mutex usage, I am unsure.

Along with cleaning up the mutex usage, I linted a lot of request.go, breaking some lines up, paragraphing, and removing an unused parameter to runLs(), so we can remove some unused path cleanup work, which then removes some imports in both server.go and request.go.

Copy link
Collaborator

@drakkan drakkan left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

@puellanivis puellanivis merged commit 792ae58 into master Aug 3, 2021
@puellanivis puellanivis deleted the cleanup-request-mutex-usage branch August 3, 2021 12:24
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