From c7a152ac24b797c181b29055cef55acbcc2eb97e Mon Sep 17 00:00:00 2001 From: chenchunlin4 Date: Fri, 27 May 2022 20:39:11 +0800 Subject: [PATCH 1/2] Avoiding the Failure to Send Big Files Through Bluetooth Signed-off-by: chenchunlin4 --- .../softbus_property/softbus_feature_config.c | 2 +- core/connection/br/src/br_connection.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/common/softbus_property/softbus_feature_config.c b/core/common/softbus_property/softbus_feature_config.c index 83ca9b5e9a..9aad1f03f6 100644 --- a/core/common/softbus_property/softbus_feature_config.c +++ b/core/common/softbus_property/softbus_feature_config.c @@ -36,7 +36,7 @@ #endif #define CONN_RFCOM_SEND_MAX_LEN 990 -#define CONN_BR_RECEIVE_MAX_LEN 50 +#define CONN_BR_RECEIVE_MAX_LEN 500 #define CONN_TCP_MAX_LENGTH 3072 #define CONN_TCP_MAX_CONN_NUM 30 #define CONN_TCP_TIME_OUT 100 diff --git a/core/connection/br/src/br_connection.c b/core/connection/br/src/br_connection.c index c5e446e87d..f1342ad2e7 100644 --- a/core/connection/br/src/br_connection.c +++ b/core/connection/br/src/br_connection.c @@ -37,6 +37,7 @@ #include "unistd.h" #include "wrapper_br_interface.h" +#define SEND_WAIT_TIMEOUT 1000 #define DISCONN_DELAY_TIME 200 #define BR_ACCEPET_WAIT_TIME 1000 #define CONNECT_REF_INCRESE 1 @@ -728,6 +729,16 @@ static int32_t DisconnectDeviceNow(const ConnectOption *option) return SOFTBUS_ERR; } +static void GetTimeDelay(uint32_t delay, struct timespec *tv) +{ +#define USECTONSEC 1000LL + SoftBusSysTime now; + (void)SoftBusGetTime(&now); + int64_t time = now.sec * USECTONSEC * USECTONSEC + now.usec + SEND_WAIT_TIMEOUT * USECTONSEC; + tv->tv_sec = time / USECTONSEC / USECTONSEC; + tv->tv_nsec = time % (USECTONSEC * USECTONSEC) * USECTONSEC; +} + void *SendHandlerLoop(void *arg) { while (1) { @@ -736,7 +747,11 @@ void *SendHandlerLoop(void *arg) break; } if (IsListEmpty(&g_dataQueue.sendList)) { - pthread_cond_wait(&g_dataQueue.cond, &g_dataQueue.lock); + SoftBusLog(SOFTBUS_LOG_CONN, SOFTBUS_LOG_INFO, "br wait send cond start"); + struct timespec tv; + GetTimeDelay(SEND_WAIT_TIMEOUT, &tv); + (void)pthread_cond_timedwait(&g_dataQueue.cond, &g_dataQueue.lock, &tv); + SoftBusLog(SOFTBUS_LOG_CONN, SOFTBUS_LOG_INFO, "br wait send cond end"); (void)pthread_mutex_unlock(&g_dataQueue.lock); continue; } -- Gitee From 3224620fff5d14193de7c93972b7778dd238e188 Mon Sep 17 00:00:00 2001 From: chenchunlin4 Date: Fri, 27 May 2022 22:29:58 +0800 Subject: [PATCH 2/2] Avoiding the Failure to Send Big Files Through Bluetooth Signed-off-by: chenchunlin4 --- core/connection/br/src/br_connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/connection/br/src/br_connection.c b/core/connection/br/src/br_connection.c index f1342ad2e7..e12f5ea1c0 100644 --- a/core/connection/br/src/br_connection.c +++ b/core/connection/br/src/br_connection.c @@ -37,7 +37,6 @@ #include "unistd.h" #include "wrapper_br_interface.h" -#define SEND_WAIT_TIMEOUT 1000 #define DISCONN_DELAY_TIME 200 #define BR_ACCEPET_WAIT_TIME 1000 #define CONNECT_REF_INCRESE 1 @@ -52,6 +51,7 @@ #define PRIORITY_MID 8 #define PRIORITY_LOW 1 #define PRIORITY_DAF 1 +#define SEND_WAIT_TIMEOUT 1000 #define BR_SERVER_NAME_LEN 24 #define UUID "8ce255c0-200a-11e0-ac64-0800200c9a66" -- Gitee