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

The sample MPD widget spawns an exponential amount of timers when no connection can be made #148

Open
potamides opened this issue Jul 9, 2020 · 1 comment

Comments

@potamides
Copy link
Contributor

Hello,
while integrating MPD into my rice i stumbled over a bug in the sample widget on the awesome website. The sample widget uses this error handler:

local function error_handler(err)
    mpd_widget:set_text("Error: " .. tostring(err))
    -- Try a reconnect soon-ish
    timer.start_new(10, function()
        connection:send("ping")
    end)
end

When mpc:_connect fails and try_reconnect is false this method gets called two times and thus two timers are created. Each timer then again calls mpc:_connect. When no connection can be made, after some time this completely stops awesome from working.

@actionless
Copy link
Member

and it never stops it - that's indeed terribly written - it should be instead a singleton-like timer, which should be stopped at some point (i think right after trying to send connection again)

PRs are welcome

actionless pushed a commit that referenced this issue Nov 19, 2023
Co-authored-by: unknown <unknown@bigvault>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants