db/proxy: move code to Disconnect()
This commit is contained in:
parent
3f0415fa24
commit
00adf7ff17
@ -83,6 +83,8 @@ private:
|
|||||||
bool Connect(Error &error);
|
bool Connect(Error &error);
|
||||||
bool CheckConnection(Error &error);
|
bool CheckConnection(Error &error);
|
||||||
bool EnsureConnected(Error &error);
|
bool EnsureConnected(Error &error);
|
||||||
|
|
||||||
|
void Disconnect();
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Domain libmpdclient_domain("libmpdclient");
|
static constexpr Domain libmpdclient_domain("libmpdclient");
|
||||||
@ -254,7 +256,7 @@ ProxyDatabase::Close()
|
|||||||
delete root;
|
delete root;
|
||||||
|
|
||||||
if (connection != nullptr)
|
if (connection != nullptr)
|
||||||
mpd_connection_free(connection);
|
Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -269,10 +271,8 @@ ProxyDatabase::Connect(Error &error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckError(connection, error)) {
|
if (!CheckError(connection, error)) {
|
||||||
if (connection != nullptr) {
|
if (connection != nullptr)
|
||||||
mpd_connection_free(connection);
|
Disconnect();
|
||||||
connection = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ ProxyDatabase::CheckConnection(Error &error)
|
|||||||
assert(connection != nullptr);
|
assert(connection != nullptr);
|
||||||
|
|
||||||
if (!mpd_connection_clear_error(connection)) {
|
if (!mpd_connection_clear_error(connection)) {
|
||||||
mpd_connection_free(connection);
|
Disconnect();
|
||||||
return Connect(error);
|
return Connect(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,6 +301,15 @@ ProxyDatabase::EnsureConnected(Error &error)
|
|||||||
: Connect(error);
|
: Connect(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ProxyDatabase::Disconnect()
|
||||||
|
{
|
||||||
|
assert(connection != nullptr);
|
||||||
|
|
||||||
|
mpd_connection_free(connection);
|
||||||
|
connection = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
static Song *
|
static Song *
|
||||||
Convert(const struct mpd_song *song);
|
Convert(const struct mpd_song *song);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user