mirror of
https://github.com/QuantumLeaps/qpc.git
synced 2025-02-04 07:13:16 +08:00
6.9.2a
Fixed potential race condition in qs_rx.c
This commit is contained in:
parent
428d023cf2
commit
7300911f1f
@ -4,8 +4,8 @@
|
|||||||
* @ingroup qs
|
* @ingroup qs
|
||||||
* @cond
|
* @cond
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* Last updated for version 6.9.2a
|
* Last updated for version 6.9.3
|
||||||
* Last updated on 2021-01-28
|
* Last updated on 2021-03-02
|
||||||
*
|
*
|
||||||
* Q u a n t u m L e a P s
|
* Q u a n t u m L e a P s
|
||||||
* ------------------------
|
* ------------------------
|
||||||
@ -288,7 +288,7 @@ bool QS_RX_PUT(uint8_t const b) {
|
|||||||
}
|
}
|
||||||
if (head != QS_rxPriv_.tail) { /* buffer NOT full? */
|
if (head != QS_rxPriv_.tail) { /* buffer NOT full? */
|
||||||
QS_rxPriv_.buf[QS_rxPriv_.head] = b;
|
QS_rxPriv_.buf[QS_rxPriv_.head] = b;
|
||||||
QS_rxPriv_.head = head;
|
QS_rxPriv_.head = head; /* update the head to a *valid* index */
|
||||||
return true; /* byte placed in the buffer */
|
return true; /* byte placed in the buffer */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -389,14 +389,15 @@ void QS_queryCurrObj(uint8_t obj_kind) {
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void QS_rxParse(void) {
|
void QS_rxParse(void) {
|
||||||
QSCtr head = QS_rxPriv_.head;
|
QSCtr tail = QS_rxPriv_.tail;
|
||||||
while (head != QS_rxPriv_.tail) { /* QS-RX buffer NOT empty? */
|
while (QS_rxPriv_.head != tail) { /* QS-RX buffer NOT empty? */
|
||||||
uint8_t b = *QS_RX_AT_(QS_rxPriv_.tail);
|
uint8_t b = *QS_RX_AT_(tail);
|
||||||
|
|
||||||
++QS_rxPriv_.tail;
|
++tail;
|
||||||
if (QS_rxPriv_.tail == QS_rxPriv_.end) {
|
if (tail == QS_rxPriv_.end) {
|
||||||
QS_rxPriv_.tail = 0U;
|
tail = 0U;
|
||||||
}
|
}
|
||||||
|
QS_rxPriv_.tail = tail; /* update the tail to a *valid* index */
|
||||||
|
|
||||||
if (l_rx.esc != 0U) { /* escaped byte arrived? */
|
if (l_rx.esc != 0U) { /* escaped byte arrived? */
|
||||||
l_rx.esc = 0U;
|
l_rx.esc = 0U;
|
||||||
@ -1058,7 +1059,7 @@ static void QS_rxHandleGoodFrame_(uint8_t state) {
|
|||||||
i = 0U; /* use 'i' as status, 0 == success,no-recycle */
|
i = 0U; /* use 'i' as status, 0 == success,no-recycle */
|
||||||
|
|
||||||
if (l_rx.var.evt.prio == 0U) { /* publish */
|
if (l_rx.var.evt.prio == 0U) { /* publish */
|
||||||
QF_PUBLISH(l_rx.var.evt.e, &QS_rxPriv_);
|
QF_publish_(l_rx.var.evt.e, &QS_rxPriv_, 0U);
|
||||||
}
|
}
|
||||||
else if (l_rx.var.evt.prio < QF_MAX_ACTIVE) {
|
else if (l_rx.var.evt.prio < QF_MAX_ACTIVE) {
|
||||||
if (QACTIVE_POST_X(QF_active_[l_rx.var.evt.prio],
|
if (QACTIVE_POST_X(QF_active_[l_rx.var.evt.prio],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user