src/plugin.c: Check "read_loop" when returning from "pthread_cond_timedwait".
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 6 Jul 2010 11:00:32 +0000 (13:00 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 6 Jul 2010 11:00:32 +0000 (13:00 +0200)
Otherwise it may take up to $Interval seconds until all read threads
shut down. This bug was introduced in version 4.8.4 (commit dbe1a7d).

src/plugin.c

index 5ff21c6..84a5abf 100644 (file)
@@ -379,12 +379,15 @@ static void *plugin_read_thread (void __attribute__((unused)) *args)
                 * we need to re-evaluate the condition every time
                 * pthread_cond_timedwait returns. */
                rc = 0;
-               while (!timeout_reached(rf->rf_next_read) && rc == 0) {
+               while ((read_loop != 0)
+                               && !timeout_reached(rf->rf_next_read)
+                               && rc == 0)
+               {
                        rc = pthread_cond_timedwait (&read_cond, &read_lock,
                                &rf->rf_next_read);
                }
 
-               /* Must hold `real_lock' when accessing `rf->rf_type'. */
+               /* Must hold `read_lock' when accessing `rf->rf_type'. */
                rf_type = rf->rf_type;
                pthread_mutex_unlock (&read_lock);