- if (conn->block_after_ACK) {
- // if we just received an ACK, wait here until a new command is to be transmitted
- if (ACK_received) {
- while (!txBuffer_pending) {
- pthread_cond_wait(&txBufferSig, &txBufferMutex);
- }
+ pthread_mutex_lock(&txBufferMutex);
+ // if we received an ACK the PM has done its job and waits for another command.
+ // We therefore can wait here as well until a new command is to be transmitted.
+ // The advantage is that the next command will be transmitted immediately without the need to wait for a receive timeout
+ if (ACK_received) {
+ while (!txBuffer_pending) {
+ pthread_cond_wait(&txBufferSig, &txBufferMutex);