Changeset 863

Show
Ignore:
Timestamp:
03/05/08 22:41:25 (9 months ago)
Author:
michux
Message:

improve error messages

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugin_mpd.c

    r862 r863  
    22 * $URL$ 
    33 * 
    4  * mpd informations v0.81 
     4 * mpd informations v0.82 
    55 * 
    66 * Copyright (C) 2006 Stefan Kuhne <sk-privat@gmx.net> 
     
    9494 
    9595#define TIMEOUT_IN_S 10 
     96#define ERROR_DISPLAY 5 
    9697 
    9798/* current song */ 
     
    126127static mpd_Connection *conn; 
    127128static char Section[] = "Plugin:MPD"; 
    128  
     129static int errorcnt = 0; 
    129130 
    130131 
     
    207208    if (conn == NULL || conn->error) { 
    208209  if (conn) { 
    209       debug("[MPD] Error: [%s], try to reconnect to [%s]:[%i]\n", conn->errorStr, host, iport); 
     210      if (errorcnt < ERROR_DISPLAY) 
     211    debug("[MPD] Error: [%s], try to reconnect to [%s]:[%i]\n", conn->errorStr, host, iport);      
    210212      mpd_closeConnection(conn); 
    211213  } else 
     
    213215 
    214216  conn = mpd_newConnection(host, iport, TIMEOUT_IN_S); 
    215   if (conn->error) { 
    216       error("[MPD] connection failed, give up..."); 
     217  if (conn->error) {       
     218      if (errorcnt < ERROR_DISPLAY) 
     219    error("[MPD] connection failed, give up..."); 
     220      if (errorcnt == ERROR_DISPLAY) 
     221    error("[MPD] stop logging, until connection is fixed!"); 
     222      errorcnt++; 
    217223      gettimeofday(&timestamp, NULL); 
    218224      return -1; 
    219225  } 
    220  
     226  errorcnt = 0; 
    221227  debug("[MPD] connection fixed..."); 
    222228    } 
     
    568574{ 
    569575    int check; 
    570     debug("[MPD] v0.81, check lcd4linux configuration file..."); 
     576    debug("[MPD] v0.82, check lcd4linux configuration file..."); 
    571577 
    572578    check = configure_mpd();