changeset 31167:09e3134b649d

Re-enable wakeup-on-signal for cache process.
author reimar
date Wed, 26 May 2010 17:56:11 +0000
parents d8929af71fe4
children a0e901aedb04
files stream/cache2.c
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stream/cache2.c	Wed May 26 17:27:38 2010 +0000
+++ b/stream/cache2.c	Wed May 26 17:56:11 2010 +0000
@@ -102,10 +102,7 @@
 {
 #if FORKED_CACHE
   // signal process to wake up immediately
-  // Disabled for now since it causes incorrect EOFs
-  // due to interrupting read syscalls - this should be
-  // fixed instead though
-//  kill(s->cache_pid, SIGUSR1);
+  kill(s->cache_pid, SIGUSR1);
 #endif
 }
 
@@ -356,11 +353,20 @@
     int sleep_count = 0;
     do {
         if (!cache_fill(s)) {
+#if FORKED_CACHE
+            // Let signal wake us up, we cannot leave this
+            // enabled since we do not handle EINTR in most places.
+            // This might need extra code to work on BSD.
+            signal(SIGUSR1, dummy_sighandler);
+#endif
             if (sleep_count < INITIAL_FILL_USLEEP_COUNT) {
                 sleep_count++;
                 usec_sleep(INITIAL_FILL_USLEEP_TIME);
             } else
                 usec_sleep(FILL_USLEEP_TIME); // idle
+#if FORKED_CACHE
+            signal(SIGUSR1, SIG_IGN);
+#endif
         } else
             sleep_count = 0;
 //        cache_stats(s->cache_data);
@@ -449,7 +455,6 @@
   use_gui = 0; // mp_msg may not use gui stuff in forked code
 #endif
   signal(SIGTERM,exit_sighandler); // kill
-  signal(SIGUSR1, dummy_sighandler); // wakeup
   cache_mainloop(s);
   // make sure forked code never leaves this function
   exit(0);