Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nimble/host: move att_truncate_to_mtu to ble_att_svr_tx_rsp #1879

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions nimble/host/src/ble_att_svr.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ static int
ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct os_mbuf *om,
uint8_t att_op, uint8_t err_status, uint16_t err_handle)
{
struct ble_l2cap_chan *chan;
struct ble_hs_conn *conn;
int do_tx;

if (hs_status != 0 && err_status == 0) {
Expand All @@ -636,13 +638,32 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct os_

if (do_tx) {
if (hs_status == 0) {
ble_hs_lock();
conn = ble_hs_conn_find(conn_handle);
if (conn == NULL) {
hs_status = BLE_HS_ENOTCONN;
ble_hs_unlock();
goto done;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this return with locked hs lock...

also I think ble_hs_conn_chan_find_by_scid() and ble_att_truncate_to_mtu() should also be under lock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}

chan = ble_hs_conn_chan_find_by_scid(conn, cid);
if (chan == NULL) {
hs_status = BLE_HS_ENOENT;
ble_hs_unlock();
goto done;
}

ble_att_truncate_to_mtu(chan, om);
ble_hs_unlock();

hs_status = ble_att_tx(conn_handle, cid, om);
om = NULL;
if (hs_status) {
err_status = BLE_ATT_ERR_UNLIKELY;
}
}

done:
if (hs_status != 0) {
STATS_INC(ble_att_stats, error_rsp_tx);

Expand Down
2 changes: 0 additions & 2 deletions nimble/host/src/ble_eatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@ ble_eatt_tx(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txom)
goto error;
}

ble_att_truncate_to_mtu(eatt->chan, txom);

rc = ble_l2cap_send(eatt->chan, txom);
if (rc == 0) {
goto done;
Expand Down
Loading