From: Max Kellermann Date: Sat, 3 Oct 2009 23:10:23 +0000 (+0200) Subject: main: reconnect at the end of timer_mpd_update() X-Git-Tag: release-0.16~175 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5ea2e9948ad49d954181838ce56c306dd1eddfe7;p=ncmpc.git main: reconnect at the end of timer_mpd_update() During timer_mpd_update(), the MPD connection may get lost. Move that reconnect test to the end of timer_mpd_update(), so we can catch it as soon as possible. There is no advantage in having it at the beginning. --- diff --git a/src/main.c b/src/main.c index f874d62..d10e42a 100644 --- a/src/main.c +++ b/src/main.c @@ -242,9 +242,6 @@ timer_mpd_update(gpointer data) { if (mpdclient_is_connected(mpd)) mpdclient_update(mpd); - else if (reconnect_source_id == 0) - reconnect_source_id = g_timeout_add(1000, timer_reconnect, - NULL); #ifndef NCMPC_MINI if (options.enable_xterm_title) @@ -254,6 +251,11 @@ timer_mpd_update(gpointer data) screen_update(mpd); mpd->events = 0; + if (!mpdclient_is_connected(mpd) && reconnect_source_id == 0) + /* reconnect when the connection is lost */ + reconnect_source_id = g_timeout_add(1000, timer_reconnect, + NULL); + return GPOINTER_TO_INT(data); }