diff --git a/lib/httpd.c b/lib/httpd.c index 28f3d3c..785c916 100644 --- a/lib/httpd.c +++ b/lib/httpd.c @@ -205,6 +205,8 @@ httpd_remove_connection(httpd_t *httpd, http_connection_t *connection) http_request_destroy(connection->request); connection->request = NULL; } + logger_log(httpd->logger, LOGGER_DEBUG, "removing connection type %s socket %d conn %p", typename[connection->type], + connection->socket_fd, connection->user_data); httpd->callbacks.conn_destroy(connection->user_data); shutdown(connection->socket_fd, SHUT_WR); closesocket(connection->socket_fd); @@ -303,6 +305,17 @@ httpd_remove_known_connections(httpd_t *httpd) { } } +void +httpd_remove_connections_by_type(httpd_t *httpd, connection_type_t type) { + for (int i = 0; i < httpd->max_connections; i++) { + http_connection_t *connection = &httpd->connections[i]; + if (!connection->connected || connection->type != type) { + continue; + } + httpd_remove_connection(httpd, connection); + } +} + static THREAD_RETVAL httpd_thread(void *arg) { diff --git a/lib/httpd.h b/lib/httpd.h index 1df0e6b..72cc137 100644 --- a/lib/httpd.h +++ b/lib/httpd.h @@ -39,6 +39,7 @@ struct httpd_callbacks_s { typedef struct httpd_callbacks_s httpd_callbacks_t; bool httpd_nohold(httpd_t *httpd); void httpd_remove_known_connections(httpd_t *httpd); +void httpd_remove_connections_by_type(httpd_t *httpd, connection_type_t type); int httpd_set_connection_type (httpd_t *http, void *user_data, connection_type_t type); int httpd_count_connection_type (httpd_t *http, connection_type_t type); diff --git a/lib/raop_handlers.h b/lib/raop_handlers.h index 0bc980e..5173ba0 100644 --- a/lib/raop_handlers.h +++ b/lib/raop_handlers.h @@ -1083,5 +1083,8 @@ raop_handler_teardown(raop_conn_t *conn, raop_rtp_mirror_destroy(conn->raop_rtp_mirror); conn->raop_rtp_mirror = NULL; } + /* shut down any HLS connections */ + httpd_remove_connections_by_type(conn->raop->httpd, CONNECTION_TYPE_HLS); + conn->raop->callbacks.video_reset(conn->raop->callbacks.cls); } }