Code

struct mpdclient: add a reconnection count
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 4 Jan 2012 17:33:29 +0000 (18:33 +0100)
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 23 May 2012 01:49:43 +0000 (03:49 +0200)
src/mpdclient.c
src/mpdclient.h

index ec058061546c23cf1033076d220b267745ff2949..685d149a3cb5004dbff5d0ad02e66cd022f86c11 100644 (file)
@@ -115,8 +115,10 @@ mpdclient_disconnect(struct mpdclient *c)
                c->idle = false;
        }
 
-       if (c->connection)
+       if (c->connection) {
                mpd_connection_free(c->connection);
+               ++c->connection_id;
+       }
        c->connection = NULL;
 
        if (c->status)
@@ -161,6 +163,8 @@ mpdclient_connect(struct mpdclient *c,
                return false;
        }
 
+       ++c->connection_id;
+
        return true;
 }
 
index 3b02681a47e953e7d7ea077afe51bd00af1fd6e8..e9234805d6443f88692fb2c689c208cd11b28921 100644 (file)
@@ -14,6 +14,12 @@ struct mpdclient {
 
        struct mpd_connection *connection;
 
+       /**
+        * This attribute is incremented whenever the connection changes
+        * (i.e. on disconnection and (re-)connection).
+        */
+       unsigned connection_id;
+
        /**
         * If this object is non-NULL, it tracks idle events.  It is
         * automatically called by mpdclient_get_connection() and