diff --git a/src/shared/att.c b/src/shared/att.c
index 715c968..6adde22 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
free(op);
}
+static void cancel_att_send_op(struct att_send_op *op)
+{
+ if (op->destroy)
+ op->destroy(op->user_data);
+
+ op->user_data = NULL;
+ op->callback = NULL;
+ op->destroy = NULL;
+}
+
struct att_notify {
unsigned int id;
uint16_t opcode;
if (att->pending_req && att->pending_req->id == id) {
/* Don't cancel the pending request; remove it's handlers */
- att->pending_req->callback = NULL;
- att->pending_req->destroy = NULL;
+ cancel_att_send_op(att->pending_req);
return true;
}
if (att->pending_ind && att->pending_ind->id == id) {
/* Don't cancel the pending indication; remove it's handlers */
- att->pending_ind->callback = NULL;
- att->pending_ind->destroy = NULL;
+ cancel_att_send_op(att->pending_ind);
return true;
}
queue_remove_all(att->ind_queue, NULL, NULL, destroy_att_send_op);
queue_remove_all(att->write_queue, NULL, NULL, destroy_att_send_op);
- if (att->pending_req) {
+ if (att->pending_req)
/* Don't cancel the pending request; remove it's handlers */
- att->pending_req->callback = NULL;
- att->pending_req->destroy = NULL;
- }
+ cancel_att_send_op(att->pending_req);
- if (att->pending_ind) {
- /* Don't cancel the pending indication; remove it's handlers */
- att->pending_ind->callback = NULL;
- att->pending_ind->destroy = NULL;
- }
+ if (att->pending_ind)
+ /* Don't cancel the pending request; remove it's handlers */
+ cancel_att_send_op(att->pending_ind);
return true;
}