-
Notifications
You must be signed in to change notification settings - Fork 81
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
Misc fixes #560
Open
mpldr
wants to merge
22
commits into
t2bot:main
Choose a base branch
from
mpldr-pulls:misc-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Misc fixes #560
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9498f39
remove util.ArrayContains
mpldr 8b0a8e6
use format strings for string building
mpldr 6dd81b1
fix send on closed channel
mpldr 3e03f07
fix panic being used as a way to communicate errors
mpldr ef35ac7
get rid of some unnecessary panics
mpldr 9518366
improve variable naming
mpldr 87964bb
introduce the concept of time into the codebase
mpldr 186f1c9
rename thumbnailing/i to thumbnailing/preview
mpldr c518070
drop model package
mpldr cc20a34
minor preview metadata backend refactoring
mpldr f81662d
inline GetID3Tags
mpldr 682b41f
move thumbnailing/u to thumbnailing/preview/metadata
mpldr edd19b2
move pipelines/_steps to pipelines/steps
mpldr ca68585
move cmd/utilities/_common to cmd/utilities/common
mpldr fadeb9a
move api/_apimeta to api/apimeta
mpldr 8515e0b
move api/_responses to api/responses
mpldr a6b6598
move api/_routers to api/routers
mpldr 6fc49c2
move api/_auth_cache to api/auth_cache
mpldr dc277e9
move api/_debug to api/debug
mpldr 1f3380e
move cmd/homeserver_live_importers/_common to cmd/homeserver_live_imp…
mpldr a31465b
move cmd/homeserver_offline_importers/_common to cmd/homeserver_offli…
mpldr 0c957d8
move cmd/homeserver_offline_exporters/_common to cmd/homeserver_offli…
mpldr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit uncomfortable to me to have the close in the goroutine when the channel is created externally - please restore the
defer close(mediaChan)
to avoid potential resource leaks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is a bug. Recovering from a panic does not remedy unclear channel ownership. The go routine for writing is no longer necessary since this is a buffered channel now. And the channel can just be closed afterwards. A simple look at the possible code paths confirms that there is no way the channel could remain unclosed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The panic recovery is indeed a bug, though the
defer close(mediaChan)
needs to be moved up near the channel creation please. The remainder of the change is fine, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is a concurrency bug. The channel closing can be deferred in the writing function, but never outside of it. Otherwise, you end with a potential write on a closed channel. And since uploading likely takes a few milliseconds more than thumbnailing (at least on reasonably fast hardware), this will happen more often than not. So the best I could do is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be blocking on a read from the channel before the
defer
would fire - if we're not, then the concurrency is broken for sure. I'm not really comfortable using a different close style in a single section of the code, and would rather go out of the way to makedefer close()
immediately after creation work reliably.