Skip to content

Fix unresponsive stall when server error occurs - #560

Merged
larson-carter merged 1 commit into
ncmpcpp:masterfrom
zaidhaan:fix-mpd-block
Dec 31, 2022
Merged

larson-carter merged 1 commit into
ncmpcpp:masterfrom
zaidhaan:fix-mpd-block

Conversation

@zaidhaan

@zaidhaan zaidhaan commented Nov 21, 2022 •

Copy link
Copy Markdown
Contributor

Fixes #559, also fixes #539 and fixes #521.

The referenced issue occurs here (Presumably, the unresponsiveness occurs due to the playlist not being properly resized. Regardless, ensuring that the resizing does happen even after an error occurs seems to solve this).

catch (MPD::ServerError &e)
{
if (e.code() == MPD_SERVER_ERROR_SYSTEM) // no playlists directory
Statusbar::print(e.what());
else
throw;
}
if (idx < Playlists.size())
Playlists.resizeList(idx);
std::sort(Playlists.beginV(), Playlists.endV(),
LocaleBasedSorting(std::locale(), Config.ignore_leading_the));

The error code received in the issue is MPD_SERVER_ERROR_UNKNOWN_CMD, which fails the if statement, and thus the code throws the error.
The problem here is throwing leaves the remaining code outside of the catch block (which handles the case where the playlist might not have been iterated through fully) unreachable.

The code already appears to be trying to handle MPD_SERVER_ERROR_SYSTEM (which in that particular instance is not that different from calling Status::handleServerError(e) anyway), so we might as well call that regardless of the error code, while not throwing anything in the process.

@larson-carter larson-carter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry for taking so long, thank you for reaching out over twitter DMs. Merged

@larson-carter
larson-carter merged commit 9f44edf into ncmpcpp:master Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants