mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'bugfix/xRingbufferSend_timeout_bug' into 'master'
bugfix(ringbuffer): Fix ringbuffer_send timeout bug See merge request !1823
This commit is contained in:
committed by
Jiang Jiang Jian
parent
45758b6be0
commit
d1c536258c
@@ -603,7 +603,6 @@ BaseType_t xRingbufferSend(RingbufHandle_t ringbuf, void *data, size_t dataSize,
|
|||||||
//we will need to wait some more.
|
//we will need to wait some more.
|
||||||
if (ticks_to_wait != portMAX_DELAY) {
|
if (ticks_to_wait != portMAX_DELAY) {
|
||||||
ticks_remaining = ticks_end - xTaskGetTickCount();
|
ticks_remaining = ticks_end - xTaskGetTickCount();
|
||||||
}
|
|
||||||
|
|
||||||
// ticks_remaining will always be less than or equal to the original ticks_to_wait,
|
// ticks_remaining will always be less than or equal to the original ticks_to_wait,
|
||||||
// unless the timeout is reached - in which case it unsigned underflows to a much
|
// unless the timeout is reached - in which case it unsigned underflows to a much
|
||||||
@@ -611,8 +610,15 @@ BaseType_t xRingbufferSend(RingbufHandle_t ringbuf, void *data, size_t dataSize,
|
|||||||
//
|
//
|
||||||
// (Check is written this non-intuitive way to allow for the case where xTaskGetTickCount()
|
// (Check is written this non-intuitive way to allow for the case where xTaskGetTickCount()
|
||||||
// has overflowed but the ticks_end value has not overflowed.)
|
// has overflowed but the ticks_end value has not overflowed.)
|
||||||
|
if(ticks_remaining > ticks_to_wait) {
|
||||||
|
//Timeout, but there is not enough free space for the item that need to be sent.
|
||||||
|
xSemaphoreGive(rb->free_space_sem);
|
||||||
|
return pdFALSE;
|
||||||
}
|
}
|
||||||
} while (ringbufferFreeMem(rb) < needed_size && ticks_remaining > 0 && ticks_remaining <= ticks_to_wait);
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} while (ringbufferFreeMem(rb) < needed_size);
|
||||||
|
|
||||||
//Lock the mux in order to make sure no one else is messing with the ringbuffer and do the copy.
|
//Lock the mux in order to make sure no one else is messing with the ringbuffer and do the copy.
|
||||||
portENTER_CRITICAL(&rb->mux);
|
portENTER_CRITICAL(&rb->mux);
|
||||||
|
Reference in New Issue
Block a user