]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix #1493 - timeshift: fix deadlock issue if streaming fails to start.
authorAdam Sutton <dev@adamsutton.me.uk>
Fri, 11 Jan 2013 11:35:41 +0000 (11:35 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Fri, 11 Jan 2013 11:35:41 +0000 (11:35 +0000)
src/timeshift.c

index 2abe6678ce3737bd2813947764dd439d5ae91575..b068c40f7359710026a85a850b0964aea1e04af6 100644 (file)
@@ -175,11 +175,14 @@ timeshift_destroy(streaming_target_t *pad)
   /* Must hold global lock */
   lock_assert(&global_lock);
 
-  /* Ensure the thread exits */
+  /* Ensure the threads exits */
   // Note: this is a workaround for the fact the Q might have been flushed
   //       in reader thread (VERY unlikely)
+  pthread_mutex_lock(&ts->state_mutex);
   sm = streaming_msg_create(SMT_EXIT);
   streaming_target_deliver2(&ts->wr_queue.sq_st, sm);
+  timeshift_write_exit(ts->rd_pipe.wr);
+  pthread_mutex_unlock(&ts->state_mutex);
 
   /* Wait for all threads */
   pthread_join(ts->rd_thread, NULL);