* [PATCH BlueZ v1] shared/att: Simplify logic of DB out of sync recovery
@ 2026-02-24 18:55 Luiz Augusto von Dentz
2026-02-24 19:10 ` Luiz Augusto von Dentz
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2026-02-24 18:55 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This removes struct pending_db_sync since it is not really necessary
to record all the field in bt_att_pdu_error_rsp, most of them can be
directly recovered from the original request and the ecode is meant
to be only BT_ATT_ERROR_DB_OUT_OF_SYNC.
---
src/shared/att.c | 101 ++++++++++++++---------------------------------
1 file changed, 30 insertions(+), 71 deletions(-)
diff --git a/src/shared/att.c b/src/shared/att.c
index f6236248874c..3d3c8cfa262a 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -35,7 +35,6 @@
#define BT_ATT_SIGNATURE_LEN 12
struct att_send_op;
-struct pending_db_sync;
struct bt_att_chan {
struct bt_att *att;
@@ -48,7 +47,7 @@ struct bt_att_chan {
struct att_send_op *pending_req;
struct att_send_op *pending_ind;
- struct pending_db_sync *pending_db_sync;
+ struct att_send_op *pending_db_sync;
bool writer_active;
bool in_req; /* There's a pending incoming request */
@@ -205,11 +204,6 @@ struct att_send_op {
void *user_data;
};
-struct pending_db_sync {
- struct att_send_op *op;
- struct bt_att_pdu_error_rsp error;
-};
-
static void destroy_att_send_op(void *data)
{
struct att_send_op *op = data;
@@ -655,10 +649,8 @@ static void bt_att_chan_free(void *data)
if (chan->pending_ind)
destroy_att_send_op(chan->pending_ind);
- if (chan->pending_db_sync) {
- destroy_att_send_op(chan->pending_db_sync->op);
- free(chan->pending_db_sync);
- }
+ if (chan->pending_db_sync)
+ destroy_att_send_op(chan->pending_db_sync);
queue_destroy(chan->queue, destroy_att_send_op);
@@ -699,8 +691,7 @@ static bool disconnect_cb(struct io *io, void *user_data)
}
if (chan->pending_db_sync) {
- disc_att_send_op(chan->pending_db_sync->op);
- free(chan->pending_db_sync);
+ disc_att_send_op(chan->pending_db_sync);
chan->pending_db_sync = NULL;
}
@@ -828,15 +819,6 @@ static bool handle_error_rsp(struct bt_att_chan *chan, uint8_t *pdu,
/* Check if this is DB_OUT_OF_SYNC and we have a callback */
if (rsp->ecode == BT_ATT_ERROR_DB_OUT_OF_SYNC &&
att->db_sync_callback) {
- struct pending_db_sync *pending;
-
- pending = new0(struct pending_db_sync, 1);
- if (!pending)
- return false;
-
- pending->op = op;
- pending->error = *rsp;
-
/* Remove timeout since we're waiting for approval */
if (op->timeout_id) {
timeout_remove(op->timeout_id);
@@ -844,13 +826,13 @@ static bool handle_error_rsp(struct bt_att_chan *chan, uint8_t *pdu,
}
/* Move to pending_db_sync */
- chan->pending_db_sync = pending;
+ chan->pending_db_sync = op;
chan->pending_req = NULL;
DBG(att, "(chan %p) DB out of sync for operation %p", chan, op);
/* Notify upper layer */
- att->db_sync_callback(&pending->error, op->pdu + 1, op->len - 1,
+ att->db_sync_callback(rsp, op->pdu + 1, op->len - 1,
op->id, att->db_sync_data);
return true;
@@ -1726,7 +1708,6 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
{
const struct queue_entry *entry;
struct att_send_op *op;
- bool from_db_sync = false;
bool result;
if (!att || !id)
@@ -1741,40 +1722,18 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
break;
/* Also check pending_db_sync */
- if (chan->pending_db_sync &&
- chan->pending_db_sync->op->id == id) {
- from_db_sync = true;
- break;
+ if (chan->pending_db_sync && chan->pending_db_sync->id == id) {
+ op = chan->pending_db_sync;
+ chan->pending_db_sync = NULL;
+ DBG(att, "(chan %p) Resending DB out of sync operation"
+ " %p", chan, op);
+ goto done;
}
}
if (!entry)
return -ENOENT;
- /* If from pending_db_sync, extract operation details if not provided */
- if (from_db_sync) {
- struct bt_att_chan *chan = entry->data;
- struct pending_db_sync *pending = chan->pending_db_sync;
- struct att_send_op *stored_op = pending->op;
-
- /* Auto-extract from stored operation if pdu is NULL */
- if (!pdu) {
- opcode = stored_op->opcode;
- pdu = stored_op->pdu + 1;
- length = stored_op->len - 1;
- callback = stored_op->callback;
- user_data = stored_op->user_data;
- destroy = stored_op->destroy;
- }
-
- DBG(att, "(chan %p) Resending DB out of sync operation %p",
- chan, stored_op);
-
- /* Clear pending_db_sync state */
- chan->pending_db_sync = NULL;
- free(pending);
- }
-
/* Only allow requests to be resend */
if (get_op_type(opcode) != ATT_OP_TYPE_REQ)
return -EOPNOTSUPP;
@@ -1786,6 +1745,7 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
op->id = id;
+done:
switch (opcode) {
/* Only prepend requests that could be a continuation */
case BT_ATT_OP_READ_BLOB_REQ:
@@ -1873,30 +1833,29 @@ bool bt_att_chan_cancel(struct bt_att_chan *chan, unsigned int id)
static bool bt_att_db_sync_cancel(struct bt_att_chan *chan, unsigned int id)
{
- if (chan->pending_db_sync && chan->pending_db_sync->op->id == id) {
- struct pending_db_sync *pending = chan->pending_db_sync;
- struct att_send_op *op = pending->op;
- uint8_t error_pdu[sizeof(struct bt_att_pdu_error_rsp)];
+ struct att_send_op *op = chan->pending_db_sync;
+ struct bt_att_pdu_error_rsp rsp;
- /* Build error response PDU */
- memcpy(error_pdu, &pending->error, sizeof(pending->error));
+ if (!op || op->id != id)
+ return false;
- /* Clear pending state */
- chan->pending_db_sync = NULL;
- free(pending);
+ /* Build error response PDU */
+ memset(&rsp, 0, sizeof(rsp));
+ rsp.opcode = op->opcode;
+ rsp.ecode = BT_ATT_ERROR_DB_OUT_OF_SYNC;
- /* Notify callback with error */
- if (op->callback)
- op->callback(BT_ATT_OP_ERROR_RSP, error_pdu,
- sizeof(error_pdu), op->user_data);
+ /* Clear pending state */
+ chan->pending_db_sync = NULL;
- destroy_att_send_op(op);
- wakeup_chan_writer(chan, NULL);
+ /* Notify callback with error */
+ if (op->callback)
+ op->callback(BT_ATT_OP_ERROR_RSP, &rsp, sizeof(rsp),
+ op->user_data);
- return true;
- }
+ destroy_att_send_op(op);
+ wakeup_chan_writer(chan, NULL);
- return false;
+ return true;
}
static bool bt_att_disc_cancel(struct bt_att *att, unsigned int id)
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH BlueZ v1] shared/att: Simplify logic of DB out of sync recovery
2026-02-24 18:55 [PATCH BlueZ v1] shared/att: Simplify logic of DB out of sync recovery Luiz Augusto von Dentz
@ 2026-02-24 19:10 ` Luiz Augusto von Dentz
2026-02-25 7:26 ` Mengshi Wu
2026-02-24 20:19 ` [BlueZ,v1] " bluez.test.bot
2026-02-25 17:50 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
2 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2026-02-24 19:10 UTC (permalink / raw)
To: linux-bluetooth, Mengshi Wu
Hi Mengshi,
On Tue, Feb 24, 2026 at 1:55 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This removes struct pending_db_sync since it is not really necessary
> to record all the field in bt_att_pdu_error_rsp, most of them can be
> directly recovered from the original request and the ecode is meant
> to be only BT_ATT_ERROR_DB_OUT_OF_SYNC.
> ---
> src/shared/att.c | 101 ++++++++++++++---------------------------------
> 1 file changed, 30 insertions(+), 71 deletions(-)
>
> diff --git a/src/shared/att.c b/src/shared/att.c
> index f6236248874c..3d3c8cfa262a 100644
> --- a/src/shared/att.c
> +++ b/src/shared/att.c
> @@ -35,7 +35,6 @@
> #define BT_ATT_SIGNATURE_LEN 12
>
> struct att_send_op;
> -struct pending_db_sync;
>
> struct bt_att_chan {
> struct bt_att *att;
> @@ -48,7 +47,7 @@ struct bt_att_chan {
>
> struct att_send_op *pending_req;
> struct att_send_op *pending_ind;
> - struct pending_db_sync *pending_db_sync;
> + struct att_send_op *pending_db_sync;
> bool writer_active;
>
> bool in_req; /* There's a pending incoming request */
> @@ -205,11 +204,6 @@ struct att_send_op {
> void *user_data;
> };
>
> -struct pending_db_sync {
> - struct att_send_op *op;
> - struct bt_att_pdu_error_rsp error;
> -};
> -
> static void destroy_att_send_op(void *data)
> {
> struct att_send_op *op = data;
> @@ -655,10 +649,8 @@ static void bt_att_chan_free(void *data)
> if (chan->pending_ind)
> destroy_att_send_op(chan->pending_ind);
>
> - if (chan->pending_db_sync) {
> - destroy_att_send_op(chan->pending_db_sync->op);
> - free(chan->pending_db_sync);
> - }
> + if (chan->pending_db_sync)
> + destroy_att_send_op(chan->pending_db_sync);
>
> queue_destroy(chan->queue, destroy_att_send_op);
>
> @@ -699,8 +691,7 @@ static bool disconnect_cb(struct io *io, void *user_data)
> }
>
> if (chan->pending_db_sync) {
> - disc_att_send_op(chan->pending_db_sync->op);
> - free(chan->pending_db_sync);
> + disc_att_send_op(chan->pending_db_sync);
> chan->pending_db_sync = NULL;
> }
>
> @@ -828,15 +819,6 @@ static bool handle_error_rsp(struct bt_att_chan *chan, uint8_t *pdu,
> /* Check if this is DB_OUT_OF_SYNC and we have a callback */
> if (rsp->ecode == BT_ATT_ERROR_DB_OUT_OF_SYNC &&
> att->db_sync_callback) {
> - struct pending_db_sync *pending;
> -
> - pending = new0(struct pending_db_sync, 1);
> - if (!pending)
> - return false;
> -
> - pending->op = op;
> - pending->error = *rsp;
> -
> /* Remove timeout since we're waiting for approval */
> if (op->timeout_id) {
> timeout_remove(op->timeout_id);
> @@ -844,13 +826,13 @@ static bool handle_error_rsp(struct bt_att_chan *chan, uint8_t *pdu,
> }
>
> /* Move to pending_db_sync */
> - chan->pending_db_sync = pending;
> + chan->pending_db_sync = op;
> chan->pending_req = NULL;
>
> DBG(att, "(chan %p) DB out of sync for operation %p", chan, op);
>
> /* Notify upper layer */
> - att->db_sync_callback(&pending->error, op->pdu + 1, op->len - 1,
> + att->db_sync_callback(rsp, op->pdu + 1, op->len - 1,
> op->id, att->db_sync_data);
>
> return true;
> @@ -1726,7 +1708,6 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
> {
> const struct queue_entry *entry;
> struct att_send_op *op;
> - bool from_db_sync = false;
> bool result;
>
> if (!att || !id)
> @@ -1741,40 +1722,18 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
> break;
>
> /* Also check pending_db_sync */
> - if (chan->pending_db_sync &&
> - chan->pending_db_sync->op->id == id) {
> - from_db_sync = true;
> - break;
> + if (chan->pending_db_sync && chan->pending_db_sync->id == id) {
> + op = chan->pending_db_sync;
> + chan->pending_db_sync = NULL;
> + DBG(att, "(chan %p) Resending DB out of sync operation"
> + " %p", chan, op);
> + goto done;
> }
> }
>
> if (!entry)
> return -ENOENT;
>
> - /* If from pending_db_sync, extract operation details if not provided */
> - if (from_db_sync) {
> - struct bt_att_chan *chan = entry->data;
> - struct pending_db_sync *pending = chan->pending_db_sync;
> - struct att_send_op *stored_op = pending->op;
> -
> - /* Auto-extract from stored operation if pdu is NULL */
> - if (!pdu) {
> - opcode = stored_op->opcode;
> - pdu = stored_op->pdu + 1;
> - length = stored_op->len - 1;
> - callback = stored_op->callback;
> - user_data = stored_op->user_data;
> - destroy = stored_op->destroy;
> - }
> -
> - DBG(att, "(chan %p) Resending DB out of sync operation %p",
> - chan, stored_op);
> -
> - /* Clear pending_db_sync state */
> - chan->pending_db_sync = NULL;
> - free(pending);
> - }
> -
> /* Only allow requests to be resend */
> if (get_op_type(opcode) != ATT_OP_TYPE_REQ)
> return -EOPNOTSUPP;
> @@ -1786,6 +1745,7 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
>
> op->id = id;
>
> +done:
> switch (opcode) {
> /* Only prepend requests that could be a continuation */
> case BT_ATT_OP_READ_BLOB_REQ:
> @@ -1873,30 +1833,29 @@ bool bt_att_chan_cancel(struct bt_att_chan *chan, unsigned int id)
>
> static bool bt_att_db_sync_cancel(struct bt_att_chan *chan, unsigned int id)
> {
> - if (chan->pending_db_sync && chan->pending_db_sync->op->id == id) {
> - struct pending_db_sync *pending = chan->pending_db_sync;
> - struct att_send_op *op = pending->op;
> - uint8_t error_pdu[sizeof(struct bt_att_pdu_error_rsp)];
> + struct att_send_op *op = chan->pending_db_sync;
> + struct bt_att_pdu_error_rsp rsp;
>
> - /* Build error response PDU */
> - memcpy(error_pdu, &pending->error, sizeof(pending->error));
> + if (!op || op->id != id)
> + return false;
>
> - /* Clear pending state */
> - chan->pending_db_sync = NULL;
> - free(pending);
> + /* Build error response PDU */
> + memset(&rsp, 0, sizeof(rsp));
> + rsp.opcode = op->opcode;
> + rsp.ecode = BT_ATT_ERROR_DB_OUT_OF_SYNC;
>
> - /* Notify callback with error */
> - if (op->callback)
> - op->callback(BT_ATT_OP_ERROR_RSP, error_pdu,
> - sizeof(error_pdu), op->user_data);
> + /* Clear pending state */
> + chan->pending_db_sync = NULL;
>
> - destroy_att_send_op(op);
> - wakeup_chan_writer(chan, NULL);
> + /* Notify callback with error */
> + if (op->callback)
> + op->callback(BT_ATT_OP_ERROR_RSP, &rsp, sizeof(rsp),
> + op->user_data);
>
> - return true;
> - }
> + destroy_att_send_op(op);
> + wakeup_chan_writer(chan, NULL);
>
> - return false;
> + return true;
> }
>
> static bool bt_att_disc_cancel(struct bt_att *att, unsigned int id)
> --
> 2.52.0
Can you verify these changes don't break anything you were testing?
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH BlueZ v1] shared/att: Simplify logic of DB out of sync recovery
2026-02-24 19:10 ` Luiz Augusto von Dentz
@ 2026-02-25 7:26 ` Mengshi Wu
0 siblings, 0 replies; 5+ messages in thread
From: Mengshi Wu @ 2026-02-25 7:26 UTC (permalink / raw)
To: Luiz Augusto von Dentz, linux-bluetooth
Hi Luiz,
On 2/25/2026 3:10 AM, Luiz Augusto von Dentz wrote:
> Hi Mengshi,
>
> On Tue, Feb 24, 2026 at 1:55 PM Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>>
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> This removes struct pending_db_sync since it is not really necessary
>> to record all the field in bt_att_pdu_error_rsp, most of them can be
>> directly recovered from the original request and the ecode is meant
>> to be only BT_ATT_ERROR_DB_OUT_OF_SYNC.
>> ---
>> src/shared/att.c | 101 ++++++++++++++---------------------------------
>> 1 file changed, 30 insertions(+), 71 deletions(-)
>>
>> diff --git a/src/shared/att.c b/src/shared/att.c
>> index f6236248874c..3d3c8cfa262a 100644
>> --- a/src/shared/att.c
>> +++ b/src/shared/att.c
>> @@ -35,7 +35,6 @@
>> #define BT_ATT_SIGNATURE_LEN 12
>>
>> struct att_send_op;
>> -struct pending_db_sync;
>>
>> struct bt_att_chan {
>> struct bt_att *att;
>> @@ -48,7 +47,7 @@ struct bt_att_chan {
>>
>> struct att_send_op *pending_req;
>> struct att_send_op *pending_ind;
>> - struct pending_db_sync *pending_db_sync;
>> + struct att_send_op *pending_db_sync;
>> bool writer_active;
>>
>> bool in_req; /* There's a pending incoming request */
>> @@ -205,11 +204,6 @@ struct att_send_op {
>> void *user_data;
>> };
>>
>> -struct pending_db_sync {
>> - struct att_send_op *op;
>> - struct bt_att_pdu_error_rsp error;
>> -};
>> -
>> static void destroy_att_send_op(void *data)
>> {
>> struct att_send_op *op = data;
>> @@ -655,10 +649,8 @@ static void bt_att_chan_free(void *data)
>> if (chan->pending_ind)
>> destroy_att_send_op(chan->pending_ind);
>>
>> - if (chan->pending_db_sync) {
>> - destroy_att_send_op(chan->pending_db_sync->op);
>> - free(chan->pending_db_sync);
>> - }
>> + if (chan->pending_db_sync)
>> + destroy_att_send_op(chan->pending_db_sync);
>>
>> queue_destroy(chan->queue, destroy_att_send_op);
>>
>> @@ -699,8 +691,7 @@ static bool disconnect_cb(struct io *io, void *user_data)
>> }
>>
>> if (chan->pending_db_sync) {
>> - disc_att_send_op(chan->pending_db_sync->op);
>> - free(chan->pending_db_sync);
>> + disc_att_send_op(chan->pending_db_sync);
>> chan->pending_db_sync = NULL;
>> }
>>
>> @@ -828,15 +819,6 @@ static bool handle_error_rsp(struct bt_att_chan *chan, uint8_t *pdu,
>> /* Check if this is DB_OUT_OF_SYNC and we have a callback */
>> if (rsp->ecode == BT_ATT_ERROR_DB_OUT_OF_SYNC &&
>> att->db_sync_callback) {
>> - struct pending_db_sync *pending;
>> -
>> - pending = new0(struct pending_db_sync, 1);
>> - if (!pending)
>> - return false;
>> -
>> - pending->op = op;
>> - pending->error = *rsp;
>> -
>> /* Remove timeout since we're waiting for approval */
>> if (op->timeout_id) {
>> timeout_remove(op->timeout_id);
>> @@ -844,13 +826,13 @@ static bool handle_error_rsp(struct bt_att_chan *chan, uint8_t *pdu,
>> }
>>
>> /* Move to pending_db_sync */
>> - chan->pending_db_sync = pending;
>> + chan->pending_db_sync = op;
>> chan->pending_req = NULL;
>>
>> DBG(att, "(chan %p) DB out of sync for operation %p", chan, op);
>>
>> /* Notify upper layer */
>> - att->db_sync_callback(&pending->error, op->pdu + 1, op->len - 1,
>> + att->db_sync_callback(rsp, op->pdu + 1, op->len - 1,
>> op->id, att->db_sync_data);
>>
>> return true;
>> @@ -1726,7 +1708,6 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
>> {
>> const struct queue_entry *entry;
>> struct att_send_op *op;
>> - bool from_db_sync = false;
>> bool result;
>>
>> if (!att || !id)
>> @@ -1741,40 +1722,18 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
>> break;
>>
>> /* Also check pending_db_sync */
>> - if (chan->pending_db_sync &&
>> - chan->pending_db_sync->op->id == id) {
>> - from_db_sync = true;
>> - break;
>> + if (chan->pending_db_sync && chan->pending_db_sync->id == id) {
>> + op = chan->pending_db_sync;
>> + chan->pending_db_sync = NULL;
>> + DBG(att, "(chan %p) Resending DB out of sync operation"
>> + " %p", chan, op);
>> + goto done;
>> }
>> }
>>
>> if (!entry)
>> return -ENOENT;
>>
>> - /* If from pending_db_sync, extract operation details if not provided */
>> - if (from_db_sync) {
>> - struct bt_att_chan *chan = entry->data;
>> - struct pending_db_sync *pending = chan->pending_db_sync;
>> - struct att_send_op *stored_op = pending->op;
>> -
>> - /* Auto-extract from stored operation if pdu is NULL */
>> - if (!pdu) {
>> - opcode = stored_op->opcode;
>> - pdu = stored_op->pdu + 1;
>> - length = stored_op->len - 1;
>> - callback = stored_op->callback;
>> - user_data = stored_op->user_data;
>> - destroy = stored_op->destroy;
>> - }
>> -
>> - DBG(att, "(chan %p) Resending DB out of sync operation %p",
>> - chan, stored_op);
>> -
>> - /* Clear pending_db_sync state */
>> - chan->pending_db_sync = NULL;
>> - free(pending);
>> - }
>> -
>> /* Only allow requests to be resend */
>> if (get_op_type(opcode) != ATT_OP_TYPE_REQ)
>> return -EOPNOTSUPP;
>> @@ -1786,6 +1745,7 @@ int bt_att_resend(struct bt_att *att, unsigned int id, uint8_t opcode,
>>
>> op->id = id;
>>
>> +done:
>> switch (opcode) {
>> /* Only prepend requests that could be a continuation */
>> case BT_ATT_OP_READ_BLOB_REQ:
>> @@ -1873,30 +1833,29 @@ bool bt_att_chan_cancel(struct bt_att_chan *chan, unsigned int id)
>>
>> static bool bt_att_db_sync_cancel(struct bt_att_chan *chan, unsigned int id)
>> {
>> - if (chan->pending_db_sync && chan->pending_db_sync->op->id == id) {
>> - struct pending_db_sync *pending = chan->pending_db_sync;
>> - struct att_send_op *op = pending->op;
>> - uint8_t error_pdu[sizeof(struct bt_att_pdu_error_rsp)];
>> + struct att_send_op *op = chan->pending_db_sync;
>> + struct bt_att_pdu_error_rsp rsp;
>>
>> - /* Build error response PDU */
>> - memcpy(error_pdu, &pending->error, sizeof(pending->error));
>> + if (!op || op->id != id)
>> + return false;
>>
>> - /* Clear pending state */
>> - chan->pending_db_sync = NULL;
>> - free(pending);
>> + /* Build error response PDU */
>> + memset(&rsp, 0, sizeof(rsp));
>> + rsp.opcode = op->opcode;
>> + rsp.ecode = BT_ATT_ERROR_DB_OUT_OF_SYNC;
>>
>> - /* Notify callback with error */
>> - if (op->callback)
>> - op->callback(BT_ATT_OP_ERROR_RSP, error_pdu,
>> - sizeof(error_pdu), op->user_data);
>> + /* Clear pending state */
>> + chan->pending_db_sync = NULL;
>>
>> - destroy_att_send_op(op);
>> - wakeup_chan_writer(chan, NULL);
>> + /* Notify callback with error */
>> + if (op->callback)
>> + op->callback(BT_ATT_OP_ERROR_RSP, &rsp, sizeof(rsp),
>> + op->user_data);
>>
>> - return true;
>> - }
>> + destroy_att_send_op(op);
>> + wakeup_chan_writer(chan, NULL);
>>
>> - return false;
>> + return true;
>> }
>>
>> static bool bt_att_disc_cancel(struct bt_att *att, unsigned int id)
>> --
>> 2.52.0
>
> Can you verify these changes don't break anything you were testing?
>
I have verified these changes, and they work as expected. Thank you
for kindly helping to simplify and improve the implementation.
Hash Match Case:
------------------
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 7
ATT: Read Request (0x0a) len 2
Handle: 0x000d
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read Request (0x0a)
Handle: 0x000d
Error: Database Out of Sync (0x12)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0xffff
Attribute type: Database Hash (0x2b2a)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 24
ATT: Read By Type Response (0x09) len 19
Attribute data length: 18
Attribute data list: 1 entry
Handle: 0x000f
Value: f74347d19eef647d97f0b2f7af502e33
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0010-0xffff
Attribute type: Database Hash (0x2b2a)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0010
Error: Attribute Not Found (0x0a)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 7
ATT: Read Request (0x0a) len 2
Handle: 0x000d
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 6
ATT: Read Response (0x0b) len 1
-------------
Hash differ case:
-------------
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 7
ATT: Read Request (0x0a) len 2
Handle: 0x000d
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read Request (0x0a)
Handle: 0x000d
Error: Database Out of Sync (0x12)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0xffff
Attribute type: Database Hash (0x2b2a)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 24
ATT: Read By Type Response (0x09) len 19
Attribute data length: 18
Attribute data list: 1 entry
Handle: 0x000f
Value: 3a6ba4cd08cf5b7f96e542822cb1b4e5
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0010-0xffff
Attribute type: Database Hash (0x2b2a)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0010
Error: Attribute Not Found (0x0a)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Primary Service (0x2800)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 24
ATT: Read By Group Type Response (0x11) len 19
Attribute data length: 6
Attribute group list: 3 entries
Handle range: 0x0001-0x0007
UUID: Generic Access Profile (0x1800)
Handle range: 0x0008-0x0011
UUID: Generic Attribute Profile (0x1801)
Handle range: 0x0012-0x0014
UUID: Device Information (0x180a)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0015-0xffff
Attribute group type: Primary Service (0x2800)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 26
ATT: Read By Group Type Response (0x11) len 21
Attribute data length: 20
Attribute group list: 1 entry
Handle range: 0x0025-0x0028
UUID: Vendor specific (12345678-1234-5678-1234-56789abcdef0)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0029-0xffff
Attribute group type: Primary Service (0x2800)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0029
Error: Attribute Not Found (0x0a)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Secondary Service (0x2801)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0001
Error: Attribute Not Found (0x0a)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0015-0x0028
Attribute type: Include (0x2802)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0015
Error: Attribute Not Found (0x0a)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0015-0x0028
Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 27
ATT: Read By Type Response (0x09) len 22
Attribute data length: 21
Attribute data list: 1 entry
Handle: 0x0026
Value: 1a2700f1debc9a785634127856341278563412
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0027-0x0028
Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0027
Error: Attribute Not Found (0x0a)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0xffff
Attribute type: Database Hash (0x2b2a)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 24
ATT: Read By Type Response (0x09) len 19
Attribute data length: 18
Attribute data list: 1 entry
Handle: 0x000f
Value: 3a6ba4cd08cf5b7f96e542822cb1b4e5
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 11
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0010-0xffff
Attribute type: Database Hash (0x2b2a)
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0010
Error: Attribute Not Found (0x0a)
bluetoothd[17265]: < ACL Data TX: Handle 4 flags 0x00 dlen 9
ATT: Write Request (0x12) len 4
Handle: 0x000b
Data: 0200
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 4
Count: 1
> ACL Data RX: Handle 4 flags 0x02 dlen 5
ATT: Write Response (0x13) len 0
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [BlueZ,v1] shared/att: Simplify logic of DB out of sync recovery
2026-02-24 18:55 [PATCH BlueZ v1] shared/att: Simplify logic of DB out of sync recovery Luiz Augusto von Dentz
2026-02-24 19:10 ` Luiz Augusto von Dentz
@ 2026-02-24 20:19 ` bluez.test.bot
2026-02-25 17:50 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
2 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2026-02-24 20:19 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1262 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1057371
---Test result---
Test Summary:
CheckPatch PENDING 0.31 seconds
GitLint PENDING 0.33 seconds
BuildEll PASS 20.67 seconds
BluezMake PASS 651.10 seconds
MakeCheck PASS 18.39 seconds
MakeDistcheck PASS 247.57 seconds
CheckValgrind PASS 295.74 seconds
CheckSmatch PASS 351.00 seconds
bluezmakeextell PASS 181.56 seconds
IncrementalBuild PENDING 0.35 seconds
ScanBuild PASS 1036.62 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ v1] shared/att: Simplify logic of DB out of sync recovery
2026-02-24 18:55 [PATCH BlueZ v1] shared/att: Simplify logic of DB out of sync recovery Luiz Augusto von Dentz
2026-02-24 19:10 ` Luiz Augusto von Dentz
2026-02-24 20:19 ` [BlueZ,v1] " bluez.test.bot
@ 2026-02-25 17:50 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2026-02-25 17:50 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hello:
This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 24 Feb 2026 13:55:24 -0500 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This removes struct pending_db_sync since it is not really necessary
> to record all the field in bt_att_pdu_error_rsp, most of them can be
> directly recovered from the original request and the ecode is meant
> to be only BT_ATT_ERROR_DB_OUT_OF_SYNC.
>
> [...]
Here is the summary with links:
- [BlueZ,v1] shared/att: Simplify logic of DB out of sync recovery
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a96f5f4eba9a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-25 17:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 18:55 [PATCH BlueZ v1] shared/att: Simplify logic of DB out of sync recovery Luiz Augusto von Dentz
2026-02-24 19:10 ` Luiz Augusto von Dentz
2026-02-25 7:26 ` Mengshi Wu
2026-02-24 20:19 ` [BlueZ,v1] " bluez.test.bot
2026-02-25 17:50 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox