From: Max Kellermann Date: Sun, 19 Mar 2017 12:02:11 +0000 (+0100) Subject: mpdclient: no mpdclient_handle_error() after connect failure X-Git-Tag: v0.26~23 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=81de90453eee773e437383699583a68683b8c520;p=ncmpc.git mpdclient: no mpdclient_handle_error() after connect failure Invoke the error callback, but don't attempt to recover. --- 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;