From ebf91aeb322da26d553cb958e17166bfde4e8136 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 4 Jan 2012 18:33:29 +0100 Subject: [PATCH] struct mpdclient: add a reconnection count --- src/mpdclient.c | 6 +++++- src/mpdclient.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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 -- 2.30.2