From: Jonathan Neuschäfer Date: Wed, 4 Jan 2012 17:33:29 +0000 (+0100) Subject: struct mpdclient: add a reconnection count X-Git-Tag: release-0.21~25^2~8 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ebf91aeb322da26d553cb958e17166bfde4e8136;p=ncmpc.git struct mpdclient: add a reconnection count --- diff --git a/src/mpdclient.c b/src/mpdclient.c index ec05806..685d149 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -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; } diff --git a/src/mpdclient.h b/src/mpdclient.h index 3b02681..e923480 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -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