[Pianod] wsgw hanging on RasPi; deadlock?

Perette Barella perette at barella.org
Mon Feb 25 16:20:27 PST 2013


Hmmm... you are correct.  Officially:
     If the current thread holds the lock on mutex, then the
     pthread_mutex_unlock() function unlocks mutex.

     Calling pthread_mutex_unlock() with a mutex that the calling thread
     does not hold will result in undefined behavior.

Unofficially, that's how both pianod and pianobar handle play/pause, so despite behavior being technically undefined cross-thread mutex unlocks seems to work pretty reliably and exactly like we want them.

Barrier waits or semaphores might be official solutions, but given it's worked in pianobar for years without trouble...

Perette


On 2013年02月25日, at 18:47, Peter Li wrote:

> Yes, that's basically the idea, although I think with a semaphore you can wait without spinning?
> 
> Although now that we're on the topic, I'm a bit confused by the mutex situation in wsgw as I thought the mutex is not supposed to be unlocked by a different thread than the one who locked it?  So maybe semaphore is more correct?
> 
> P




More information about the Pianod mailing list