From 04666fcda2dd65aeb04d88937eaca7e5c5a9772a Mon Sep 17 00:00:00 2001 From: JanierVan Date: Thu, 23 Nov 2023 15:07:36 +0800 Subject: [PATCH] fix: failures when multiple invocation interfaces in short intervals Signed-off-by: JanierVan --- .../common/net/bluetooth/ble/softbus_adapter_ble_gatt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/adapter/common/net/bluetooth/ble/softbus_adapter_ble_gatt.c b/adapter/common/net/bluetooth/ble/softbus_adapter_ble_gatt.c index 59bd5a257..03cbccbcd 100644 --- a/adapter/common/net/bluetooth/ble/softbus_adapter_ble_gatt.c +++ b/adapter/common/net/bluetooth/ble/softbus_adapter_ble_gatt.c @@ -787,10 +787,15 @@ int SoftBusStartAdv(int advId, const SoftBusBleAdvParams *param) StartAdvRawData advData; ConvertAdvParam(param, &dstParam); ConvertAdvData(&g_advChannel[advId].advData, &advData); + + if (g_advChannel[advId].advId != -1) { + CLOGE("advId not -1, %d", g_advChannel[advId].advId); + SoftBusMutexUnlock(&g_advLock); + return SOFTBUS_ERR; + } int ret = BleStartAdvEx(&btAdvId, advData, dstParam); g_advChannel[advId].advId = btAdvId; - CLOGI("BleStartAdvEx, inner-advId: %d, bt-advId: %d, " - "ret: %d", advId, btAdvId, ret); + CLOGI("BleStartAdvEx, inner-advId: %d, bt-advId: %d, ret: %d", advId, btAdvId, ret); if (ret != OHOS_BT_STATUS_SUCCESS) { g_advChannel[advId].advCallback->AdvEnableCallback(advId, SOFTBUS_BT_STATUS_FAIL); SoftBusMutexUnlock(&g_advLock);