Change while to if on txcmd_pending (per @pwpiwi comment); add note on race condition ugliness.

This commit is contained in:
Michael Farrell 2017-11-22 22:07:23 +11:00
commit 006bedd3f1

View file

@ -92,13 +92,14 @@ void SendCommand(UsbCommand *c) {
// unresponsive or disconnected. The main console thread is alive, but comm
// thread just spins here. Not good.../holiman
pthread_mutex_lock(&txcmd_lock);
while (txcmd_pending) {
if (txcmd_pending) {
// Receiver thread will signal when it is ready for us to continue.
pthread_cond_wait(&txcmd_sig, &txcmd_lock);
}
// Send command buffer to receiver thread for processing. This is slower, but
// there are many race conditions which would otherwise be triggered.
// there may be race conditions which would otherwise be triggered.
// Introduced in https://github.com/Proxmark/proxmark3/commit/f0ba634
txcmd = *c;
txcmd_pending = true;