From 5ea2e9948ad49d954181838ce56c306dd1eddfe7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 4 Oct 2009 01:10:23 +0200 Subject: [PATCH] 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. --- src/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); } -- 2.30.2