aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_mpd.c
diff options
context:
space:
mode:
authormichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2008-03-05 21:41:25 +0000
committermichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2008-03-05 21:41:25 +0000
commitf8e1cb6dfad58e737503840353ba9713409907b7 (patch)
tree64d2d818989802ff9b04bd4218ac3f4c7b4e3abc /plugin_mpd.c
parent86bf4cf15d18dc2ef7fd9e65e1e0d7f49d60480b (diff)
downloadlcd4linux-f8e1cb6dfad58e737503840353ba9713409907b7.tar.gz
improve error messages
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@863 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_mpd.c')
-rw-r--r--plugin_mpd.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/plugin_mpd.c b/plugin_mpd.c
index e94af5e..b644a8a 100644
--- a/plugin_mpd.c
+++ b/plugin_mpd.c
@@ -1,7 +1,7 @@
/* $Id$
* $URL$
*
- * mpd informations v0.81
+ * mpd informations v0.82
*
* Copyright (C) 2006 Stefan Kuhne <sk-privat@gmx.net>
* Copyright (C) 2007 Robert Buchholz <rbu@gentoo.org>
@@ -93,6 +93,7 @@ TODO:
#endif
#define TIMEOUT_IN_S 10
+#define ERROR_DISPLAY 5
/* current song */
@@ -125,7 +126,7 @@ struct timeval timestamp;
static mpd_Connection *conn;
static char Section[] = "Plugin:MPD";
-
+static int errorcnt = 0;
static int configure_mpd(void)
@@ -206,18 +207,23 @@ static int mpd_update()
/* check if connected */
if (conn == NULL || conn->error) {
if (conn) {
- debug("[MPD] Error: [%s], try to reconnect to [%s]:[%i]\n", conn->errorStr, host, iport);
+ if (errorcnt < ERROR_DISPLAY)
+ debug("[MPD] Error: [%s], try to reconnect to [%s]:[%i]\n", conn->errorStr, host, iport);
mpd_closeConnection(conn);
} else
debug("[MPD] initialize connect to [%s]:[%i]\n", host, iport);
conn = mpd_newConnection(host, iport, TIMEOUT_IN_S);
- if (conn->error) {
- error("[MPD] connection failed, give up...");
+ if (conn->error) {
+ if (errorcnt < ERROR_DISPLAY)
+ error("[MPD] connection failed, give up...");
+ if (errorcnt == ERROR_DISPLAY)
+ error("[MPD] stop logging, until connection is fixed!");
+ errorcnt++;
gettimeofday(&timestamp, NULL);
return -1;
}
-
+ errorcnt = 0;
debug("[MPD] connection fixed...");
}
@@ -567,7 +573,7 @@ static void formatTimeDDHHMM(RESULT * result, RESULT * param)
int plugin_init_mpd(void)
{
int check;
- debug("[MPD] v0.81, check lcd4linux configuration file...");
+ debug("[MPD] v0.82, check lcd4linux configuration file...");
check = configure_mpd();
if (plugin_enabled != 1)