File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -994,23 +994,25 @@ int8_t AsyncClient::_close() {
994
994
}
995
995
996
996
bool AsyncClient::_allocate_closed_slot () {
997
- if (_closed_slot != INVALID_CLOSED_SLOT) {
998
- return true ;
999
- }
997
+ bool allocated = false ;
1000
998
if (xSemaphoreTake (_slots_lock, portMAX_DELAY) == pdTRUE) {
1001
999
uint32_t closed_slot_min_index = 0 ;
1002
- for (int i = 0 ; i < _number_of_closed_slots; ++i) {
1003
- if ((_closed_slot == INVALID_CLOSED_SLOT || _closed_slots[i] <= closed_slot_min_index) && _closed_slots[i] != 0 ) {
1004
- closed_slot_min_index = _closed_slots[i];
1005
- _closed_slot = i;
1000
+ allocated = _closed_slot != INVALID_CLOSED_SLOT;
1001
+ if (!allocated) {
1002
+ for (int i = 0 ; i < _number_of_closed_slots; ++i) {
1003
+ if ((_closed_slot == INVALID_CLOSED_SLOT || _closed_slots[i] <= closed_slot_min_index) && _closed_slots[i] != 0 ) {
1004
+ closed_slot_min_index = _closed_slots[i];
1005
+ _closed_slot = i;
1006
+ }
1007
+ }
1008
+ allocated = _closed_slot != INVALID_CLOSED_SLOT;
1009
+ if (allocated) {
1010
+ _closed_slots[_closed_slot] = 0 ;
1006
1011
}
1007
- }
1008
- if (_closed_slot != INVALID_CLOSED_SLOT) {
1009
- _closed_slots[_closed_slot] = 0 ;
1010
1012
}
1011
1013
xSemaphoreGive (_slots_lock);
1012
1014
}
1013
- return (_closed_slot != INVALID_CLOSED_SLOT) ;
1015
+ return allocated ;
1014
1016
}
1015
1017
1016
1018
void AsyncClient::_free_closed_slot () {
You can’t perform that action at this time.
0 commit comments