Просмотр исходного кода

Merge branch 'bugfix/ringbuf_send_semaphore_release_order_v4.4' into 'release/v4.4'

esp_ringbuf: Fix order of semaphore release in xRingbufferSend (v4.4)

See merge request espressif/esp-idf!16229
Jiang Jiang Jian 4 лет назад
Родитель
Сommit
f2db4c7520
1 измененных файлов с 11 добавлено и 19 удалено
  1. 11 19
      components/esp_ringbuf/ringbuf.c

+ 11 - 19
components/esp_ringbuf/ringbuf.c

@@ -1,16 +1,8 @@
-// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+/*
+ * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 
 #include <stdlib.h>
 #include <string.h>
@@ -1076,13 +1068,13 @@ BaseType_t xRingbufferSend(RingbufHandle_t xRingbuffer,
          */
     }
 
+    if (xReturnSemaphore == pdTRUE) {
+        xSemaphoreGive(rbGET_TX_SEM_HANDLE(pxRingbuffer));  //Give back semaphore so other tasks can send
+    }
     if (xReturn == pdTRUE) {
         //Indicate item was successfully sent
         xSemaphoreGive(rbGET_RX_SEM_HANDLE(pxRingbuffer));
     }
-    if (xReturnSemaphore == pdTRUE) {
-        xSemaphoreGive(rbGET_TX_SEM_HANDLE(pxRingbuffer));  //Give back semaphore so other tasks can send
-    }
     return xReturn;
 }
 
@@ -1118,13 +1110,13 @@ BaseType_t xRingbufferSendFromISR(RingbufHandle_t xRingbuffer,
     }
     portEXIT_CRITICAL_ISR(&pxRingbuffer->mux);
 
+    if (xReturnSemaphore == pdTRUE) {
+        xSemaphoreGiveFromISR(rbGET_TX_SEM_HANDLE(pxRingbuffer), pxHigherPriorityTaskWoken);  //Give back semaphore so other tasks can send
+    }
     if (xReturn == pdTRUE) {
         //Indicate item was successfully sent
         xSemaphoreGiveFromISR(rbGET_RX_SEM_HANDLE(pxRingbuffer), pxHigherPriorityTaskWoken);
     }
-    if (xReturnSemaphore == pdTRUE) {
-        xSemaphoreGiveFromISR(rbGET_TX_SEM_HANDLE(pxRingbuffer), pxHigherPriorityTaskWoken);  //Give back semaphore so other tasks can send
-    }
     return xReturn;
 }