From 5a07328a9a9a583cda25def5bacfb86c31ed8984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Mon, 19 Nov 2012 09:17:44 +0100 Subject: [PATCH] HTPS: Maintain a global list of HTSP connections This is useful for post mortem debugging --- src/htsp_server.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/htsp_server.c b/src/htsp_server.c index dc17c199..05ff068f 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -71,6 +71,7 @@ TAILQ_HEAD(htsp_msg_queue, htsp_msg); TAILQ_HEAD(htsp_msg_q_queue, htsp_msg_q); static struct htsp_connection_list htsp_async_connections; +static struct htsp_connection_list htsp_connections; static void htsp_streaming_input(void *opaque, streaming_message_t *sm); @@ -107,6 +108,8 @@ typedef struct htsp_msg_q { * */ typedef struct htsp_connection { + LIST_ENTRY(htsp_connection) htsp_link; + int htsp_fd; struct sockaddr_in *htsp_peer; @@ -1760,6 +1763,10 @@ htsp_serve(int fd, void *opaque, struct sockaddr_in *source, htsp.htsp_peer = source; htsp.htsp_writer_run = 1; + pthread_mutex_lock(&global_lock); + LIST_INSERT_HEAD(&htsp_connections, &htsp, htsp_link); + pthread_mutex_unlock(&global_lock); + pthread_create(&htsp.htsp_writer_thread, NULL, htsp_write_scheduler, &htsp); /** @@ -1786,6 +1793,8 @@ htsp_serve(int fd, void *opaque, struct sockaddr_in *source, if(htsp.htsp_async_mode) LIST_REMOVE(&htsp, htsp_async_link); + LIST_REMOVE(&htsp, htsp_link); + pthread_mutex_unlock(&global_lock); pthread_mutex_lock(&htsp.htsp_out_mutex);