HTSP: Plug possible memory leak at HTSP disconnect

If subscriber is slow we will leak memory because buffered packets
will not be free'd upon HTSP session close
This commit is contained in:
Andreas Öman 2012-11-08 14:21:39 +01:00
parent 03f7bc187b
commit 683b0f9c8b

View file

@ -1564,6 +1564,17 @@ htsp_serve(int fd, void *opaque, struct sockaddr_in *source,
pthread_mutex_unlock(&htsp.htsp_out_mutex);
pthread_join(htsp.htsp_writer_thread, NULL);
htsp_msg_q_t *hmq;
TAILQ_FOREACH(hmq, &htsp.htsp_active_output_queues, hmq_link) {
htsp_msg_t *hm;
while((hm = TAILQ_FIRST(&hmq->hmq_q)) != NULL) {
TAILQ_REMOVE(&hmq->hmq_q, hm, hm_link);
htsp_msg_destroy(hm);
}
}
close(fd);
}