svcmgr: don't send reply to one-way txn (part deux)
Do not split transaction into two when sending synchronous responses.
Partially revert changes associated with binder_send_reply from
previous incantations in commit 51f592c7bad13d3d8e8f7cfec25edfef42901802
that resulted in a performance regression.
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 27111612
Bug: 28696050
Bug: 28946245
Change-Id: I12edc10a2d1408a71507a7983afa7f17b5a6a81b
diff --git a/cmds/servicemanager/binder.c b/cmds/servicemanager/binder.c
index 01218c9..27c461a 100644
--- a/cmds/servicemanager/binder.c
+++ b/cmds/servicemanager/binder.c
@@ -181,13 +181,18 @@
void binder_send_reply(struct binder_state *bs,
struct binder_io *reply,
+ binder_uintptr_t buffer_to_free,
int status)
{
struct {
+ uint32_t cmd_free;
+ binder_uintptr_t buffer;
uint32_t cmd_reply;
struct binder_transaction_data txn;
} __attribute__((packed)) data;
+ data.cmd_free = BC_FREE_BUFFER;
+ data.buffer = buffer_to_free;
data.cmd_reply = BC_REPLY;
data.txn.target.ptr = 0;
data.txn.cookie = 0;
@@ -250,9 +255,11 @@
bio_init(&reply, rdata, sizeof(rdata), 4);
bio_init_from_txn(&msg, txn);
res = func(bs, txn, &msg, &reply);
- binder_free_buffer(bs, txn->data.ptr.buffer);
- if ((txn->flags & TF_ONE_WAY) == 0)
- binder_send_reply(bs, &reply, res);
+ if (txn->flags & TF_ONE_WAY) {
+ binder_free_buffer(bs, txn->data.ptr.buffer);
+ } else {
+ binder_send_reply(bs, &reply, txn->data.ptr.buffer, res);
+ }
}
ptr += sizeof(*txn);
break;