diff options
author | Max Kellermann <max@duempel.org> | 2014-01-11 00:21:29 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-11 00:46:33 +0100 |
commit | 00adf7ff173afbe7fe13734a27d6ee19096ce640 (patch) | |
tree | fc83a8daf6d4367d57a69319214b6796e51b9d6f /src/db | |
parent | 3f0415fa24efdb3b5c7df1acfa38cfe78b3a00a3 (diff) | |
download | mpd-00adf7ff173afbe7fe13734a27d6ee19096ce640.tar.gz mpd-00adf7ff173afbe7fe13734a27d6ee19096ce640.tar.xz mpd-00adf7ff173afbe7fe13734a27d6ee19096ce640.zip |
db/proxy: move code to Disconnect()
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/ProxyDatabasePlugin.cxx | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index 94ed72263..344edb900 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -83,6 +83,8 @@ private: bool Connect(Error &error); bool CheckConnection(Error &error); bool EnsureConnected(Error &error); + + void Disconnect(); }; static constexpr Domain libmpdclient_domain("libmpdclient"); @@ -254,7 +256,7 @@ ProxyDatabase::Close() delete root; if (connection != nullptr) - mpd_connection_free(connection); + Disconnect(); } bool @@ -269,10 +271,8 @@ ProxyDatabase::Connect(Error &error) } if (!CheckError(connection, error)) { - if (connection != nullptr) { - mpd_connection_free(connection); - connection = nullptr; - } + if (connection != nullptr) + Disconnect(); return false; } @@ -286,7 +286,7 @@ ProxyDatabase::CheckConnection(Error &error) assert(connection != nullptr); if (!mpd_connection_clear_error(connection)) { - mpd_connection_free(connection); + Disconnect(); return Connect(error); } @@ -301,6 +301,15 @@ ProxyDatabase::EnsureConnected(Error &error) : Connect(error); } +void +ProxyDatabase::Disconnect() +{ + assert(connection != nullptr); + + mpd_connection_free(connection); + connection = nullptr; +} + static Song * Convert(const struct mpd_song *song); |