awesomeWM/awesome-www

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

potamides opened this issue · 1 comments

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.

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