From 006bedd3f1a847c33232587cb4fd015ba589fb28 Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Wed, 22 Nov 2017 22:07:23 +1100 Subject: [PATCH] Change `while` to `if` on `txcmd_pending` (per @pwpiwi comment); add note on race condition ugliness. --- client/comms.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/comms.c b/client/comms.c index 73d3735d..74e87762 100644 --- a/client/comms.c +++ b/client/comms.c @@ -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;