[librespot-c] Close connection if peer disconnects

Attempt to fix possible bad state where librespot-c keeps try to using a
connection even after the access point has disconnected.
This commit is contained in:
ejurgensen 2021-10-30 23:54:00 +02:00
parent 5e66dbd8c9
commit 6d54886030
1 changed files with 6 additions and 7 deletions

View File

@ -220,15 +220,12 @@ session_return(struct sp_session *session, enum sp_error err)
commands_exec_end(sp_cmdbase, err); commands_exec_end(sp_cmdbase, err);
} }
// Rolls back from an error situation. If it is a failed login then the session // Disconnects after an error situation. If it is a failed login then the
// will be closed, but if it just a connection timeout we keep the session, but // session, otherwise we end download and disconnect.
// drop the ongoing download.
static void static void
session_error(struct sp_session *session, enum sp_error err) session_error(struct sp_session *session, enum sp_error err)
{ {
struct sp_channel *channel = session->now_streaming_channel; sp_cb.logmsg("Session error: %d (occurred before msg %d, queue %d)\n", err, session->msg_type_next, session->msg_type_queued);
sp_cb.logmsg("Session error: %d\n", err);
session_return(session, err); session_return(session, err);
@ -238,8 +235,10 @@ session_error(struct sp_session *session, enum sp_error err)
return; return;
} }
channel_free(channel); channel_free_all(session);
session->now_streaming_channel = NULL; session->now_streaming_channel = NULL;
ap_disconnect(&session->conn);
} }