Skip to content

Commit 4212416

Browse files
LingaoMrlubos
authored andcommitted
[nrf fromtree] Bluetooth: Mesh: Fix Assert in bt_mesh_adv_unref when messages to a proxy
Fixes:zephyrproject-rtos/zephyr#83904 This solution fix is to define a separate variable for the each proxy FIFO. Signed-off-by: Lingao Meng <[email protected]> (cherry picked from commit 6371080) Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent 523f420 commit 4212416

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

subsys/bluetooth/mesh/adv.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ struct bt_mesh_adv_ctx {
5858
};
5959

6060
struct bt_mesh_adv {
61-
sys_snode_t node;
61+
void *adv_bearer;
62+
63+
#if defined(CONFIG_BT_MESH_GATT)
64+
void *gatt_bearer[CONFIG_BT_MAX_CONN];
65+
#endif
6266

6367
struct bt_mesh_adv_ctx ctx;
6468

subsys/bluetooth/mesh/proxy_msg.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ static struct bt_mesh_proxy_role roles[CONFIG_BT_MAX_CONN];
5656

5757
static int conn_count;
5858

59+
static void proxy_queue_put(struct bt_mesh_proxy_role *role, struct bt_mesh_adv *adv)
60+
{
61+
k_fifo_put(&role->pending, &(adv->gatt_bearer[bt_conn_index(role->conn)]));
62+
}
63+
64+
static struct bt_mesh_adv *proxy_queue_get(struct bt_mesh_proxy_role *role)
65+
{
66+
void *gatt_bearer;
67+
68+
gatt_bearer = k_fifo_get(&role->pending, K_NO_WAIT);
69+
if (!gatt_bearer) {
70+
return NULL;
71+
}
72+
73+
return CONTAINER_OF(gatt_bearer, struct bt_mesh_adv,
74+
gatt_bearer[bt_conn_index(role->conn)]);
75+
}
76+
5977
static void proxy_sar_timeout(struct k_work *work)
6078
{
6179
struct bt_mesh_proxy_role *role;
@@ -66,7 +84,7 @@ static void proxy_sar_timeout(struct k_work *work)
6684
role = CONTAINER_OF(dwork, struct bt_mesh_proxy_role, sar_timer);
6785

6886
while (!k_fifo_is_empty(&role->pending)) {
69-
struct bt_mesh_adv *adv = k_fifo_get(&role->pending, K_NO_WAIT);
87+
struct bt_mesh_adv *adv = proxy_queue_get(role);
7088

7189
__ASSERT_NO_MSG(adv);
7290

@@ -243,7 +261,7 @@ int bt_mesh_proxy_relay_send(struct bt_conn *conn, struct bt_mesh_adv *adv)
243261
{
244262
struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)];
245263

246-
k_fifo_put(&role->pending, bt_mesh_adv_ref(adv));
264+
proxy_queue_put(role, bt_mesh_adv_ref(adv));
247265

248266
bt_mesh_wq_submit(&role->work);
249267

@@ -259,7 +277,7 @@ static void proxy_msg_send_pending(struct k_work *work)
259277
return;
260278
}
261279

262-
adv = k_fifo_get(&role->pending, K_NO_WAIT);
280+
adv = proxy_queue_get(role);
263281
if (!adv) {
264282
return;
265283
}

0 commit comments

Comments
 (0)