Index: programs/mythbackend/autoexpire.h =================================================================== --- programs/mythbackend/autoexpire.h (revision 13559) +++ programs/mythbackend/autoexpire.h (working copy) @@ -74,13 +74,14 @@ QDateTime starttime); // main expire info - set dont_expire_set; - pthread_t expire_thread; - QMutex instance_lock; - size_t desired_space; - uint desired_freq; - size_t max_record_rate; // bytes/sec - bool expire_thread_running; + set dont_expire_set; + pthread_t expire_thread; + QMutex instance_lock; + QWaitCondition instance_cond; + size_t desired_space; + uint desired_freq; + size_t max_record_rate; // bytes/sec + bool expire_thread_running; // update info bool update_pending; Index: programs/mythbackend/autoexpire.cpp =================================================================== --- programs/mythbackend/autoexpire.cpp (revision 13559) +++ programs/mythbackend/autoexpire.cpp (working copy) @@ -57,13 +57,8 @@ Init(); - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - pthread_create(&expire_thread, &attr, ExpirerThread, this); + pthread_create(&expire_thread, NULL, ExpirerThread, this); gContext->addListener(this); - } /** \fn AutoExpire::AutoExpire() @@ -92,8 +87,11 @@ */ AutoExpire::~AutoExpire() { + instance_lock.lock(); while (update_pending) - usleep(500); + instance_cond.wait(&instance_lock); + instance_lock.unlock(); + if (expire_thread_running) { gContext->removeListener(this); @@ -920,6 +918,7 @@ ae->CalcParams(); ae->instance_lock.lock(); ae->update_pending = false; + ae->instance_cond.wakeAll(); ae->instance_lock.unlock(); return NULL; } @@ -941,13 +940,8 @@ // make sure there is only one update pending expirer->instance_lock.lock(); while (expirer->update_pending) - { - expirer->instance_lock.unlock(); - usleep(500); - expirer->instance_lock.lock(); - } + expirer->instance_cond.wait(&expirer->instance_lock); expirer->update_pending = true; - expirer->instance_lock.unlock(); // do it..