diff options
author | Jakub Tyszkowski <jakub.tyszkowski@tieto.com> | 2015-02-11 15:34:04 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2015-02-13 12:31:24 +0100 |
commit | 27c8b368c8f3720c77b1eb2d22d6841e1653a71e (patch) | |
tree | 8f98738fd65334e6499054e1c1bf312a66d53604 /android/gatt.c | |
parent | 25c982250e0b25d3820c86d7d12522308c682722 (diff) | |
download | bluez-27c8b368c8f3720c77b1eb2d22d6841e1653a71e.tar.gz |
android/gatt: Improve send_dev_complete_response
For simple reads or writes there is no need to take the request out
of the queue as it is destroyed at the end anyway. We can peek and
check for errors even before switch statement.
Diffstat (limited to 'android/gatt.c')
-rw-r--r-- | android/gatt.c | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/android/gatt.c b/android/gatt.c index 7f95226a1..44b3f0424 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -4461,6 +4461,17 @@ static void send_dev_complete_response(struct gatt_device *device, return; } + val = queue_peek_head(device->pending_requests); + if (!val) { + error = ATT_ECODE_ATTR_NOT_FOUND; + goto done; + } + + if (val->error) { + error = val->error; + goto done; + } + switch (opcode) { case ATT_OP_READ_BY_TYPE_REQ: { struct att_data_list *adl; @@ -4520,25 +4531,11 @@ static void send_dev_complete_response(struct gatt_device *device, break; } case ATT_OP_READ_BLOB_REQ: - val = queue_pop_head(device->pending_requests); - if (val->error) { - error = val->error; - goto done; - } - len = enc_read_blob_resp(val->value, val->length, val->offset, rsp, mtu); - destroy_pending_request(val); break; case ATT_OP_READ_REQ: - val = queue_pop_head(device->pending_requests); - if (val->error) { - error = val->error; - goto done; - } - len = enc_read_resp(val->value, val->length, rsp, mtu); - destroy_pending_request(val); break; case ATT_OP_READ_BY_GROUP_REQ: { struct att_data_list *adl; @@ -4644,39 +4641,17 @@ static void send_dev_complete_response(struct gatt_device *device, break; } case ATT_OP_EXEC_WRITE_REQ: - val = queue_pop_head(device->pending_requests); - if (val->error) { - error = val->error; - goto done; - } - len = enc_exec_write_resp(rsp); - destroy_pending_request(val); break; case ATT_OP_WRITE_REQ: - val = queue_pop_head(device->pending_requests); - if (val->error) { - error = val->error; - goto done; - } - len = enc_write_resp(rsp); - destroy_pending_request(val); break; case ATT_OP_PREP_WRITE_REQ: { uint16_t handle; - val = queue_pop_head(device->pending_requests); - if (val->error) { - error = val->error; - goto done; - } - handle = gatt_db_attribute_get_handle(val->attrib); - len = enc_prep_write_resp(handle, val->offset, val->value, val->length, rsp, mtu); - destroy_pending_request(val); break; } default: |