From 81de90453eee773e437383699583a68683b8c520 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 19 Mar 2017 13:02:11 +0100 Subject: [PATCH] mpdclient: no mpdclient_handle_error() after connect failure Invoke the error callback, but don't attempt to recover. --- src/mpdclient.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mpdclient.c b/src/mpdclient.c index 1a059d5..6e6dd99 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -77,6 +77,21 @@ mpdclient_invoke_error_callback(enum mpd_error error, g_free(allocated); } +static void +mpdclient_invoke_error_callback1(struct mpdclient *c) +{ + assert(c != NULL); + assert(c->connection != NULL); + + struct mpd_connection *connection = c->connection; + + enum mpd_error error = mpd_connection_get_error(connection); + assert(error != MPD_ERROR_SUCCESS); + + mpdclient_invoke_error_callback(error, + mpd_connection_get_error_message(connection)); +} + static void mpdclient_gidle_callback(enum mpd_error error, gcc_unused enum mpd_server_error server_error, @@ -214,7 +229,7 @@ mpdclient_connect(struct mpdclient *c) g_error("Out of memory"); if (mpd_connection_get_error(c->connection) != MPD_ERROR_SUCCESS) { - mpdclient_handle_error(c); + mpdclient_invoke_error_callback1(c); mpdclient_disconnect(c); mpdclient_failed_callback(); return false; @@ -223,7 +238,7 @@ mpdclient_connect(struct mpdclient *c) /* send password */ if (c->password != NULL && !mpd_run_password(c->connection, c->password)) { - mpdclient_handle_error(c); + mpdclient_invoke_error_callback1(c); mpdclient_disconnect(c); mpdclient_failed_callback(); return false; -- 2.30.2