]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
HTPS: Maintain a global list of HTSP connections
authorAndreas Öman <andreas@lonelycoder.com>
Mon, 19 Nov 2012 08:17:44 +0000 (09:17 +0100)
committerAndreas Öman <andreas@lonelycoder.com>
Mon, 19 Nov 2012 13:46:50 +0000 (14:46 +0100)
This is useful for post mortem debugging

src/htsp_server.c

index dc17c199fd97da2c0a810e093ac783dd74a611be..05ff068ff8feaa693f5d178ab36746b783bf530d 100644 (file)
@@ -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);