mirror of
https://gitee.com/openharmony/communication_ipc
synced 2024-11-23 07:50:24 +00:00
fix: Enhance the nested processing capability of sendrequest2.0
Signed-off-by: jialinbo <jialinbo@huawei.com>
This commit is contained in:
parent
f112b0effd
commit
0accb5b824
@ -245,7 +245,7 @@ private:
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(BinderInvoker);
|
||||
static constexpr int IPC_DEFAULT_PARCEL_SIZE = 256;
|
||||
static constexpr int IPC_DEFAULT_PARCEL_SIZE = 512;
|
||||
static constexpr int IPC_CMD_PROCESS_WARN_TIME = 500;
|
||||
static constexpr int ACCESS_TOKEN_MAX_LEN = 10;
|
||||
Parcel input_;
|
||||
|
@ -495,6 +495,7 @@ int BinderInvoker::FlushCommands(IRemoteObject *object)
|
||||
}
|
||||
if (error != ERR_NONE || output_.GetDataSize() > 0) {
|
||||
ZLOGW(LABEL, "error:%{public}d, left data size:%{public}zu", error, output_.GetDataSize());
|
||||
PrintParcelData(input_, "input_");
|
||||
PrintParcelData(output_, "output_");
|
||||
std::string backtrace;
|
||||
if (!GetBacktraceStringByTid(backtrace, gettid(), 0, false)) {
|
||||
@ -529,6 +530,9 @@ void BinderInvoker::StartWorkLoop()
|
||||
ZLOGE(LABEL, "returned unexpected error:%{public}d, aborting", error);
|
||||
break;
|
||||
}
|
||||
if (input_.GetReadableBytes() == 0) {
|
||||
continue;
|
||||
}
|
||||
uint32_t cmd = input_.ReadUint32();
|
||||
IPCProcessSkeleton *current = IPCProcessSkeleton::GetCurrent();
|
||||
if (current != nullptr) {
|
||||
@ -587,7 +591,6 @@ void BinderInvoker::OnBinderDied()
|
||||
ZLOGW(LABEL, "failed to increment strong reference count");
|
||||
}
|
||||
}
|
||||
|
||||
size_t rewindPos = output_.GetWritePosition();
|
||||
if (!output_.WriteInt32(BC_DEAD_BINDER_DONE)) {
|
||||
return;
|
||||
@ -616,6 +619,7 @@ void BinderInvoker::OnAcquireObject(uint32_t cmd)
|
||||
ZLOGE(LABEL, "%{public}u is invalid", ProcessSkeleton::ConvertAddr(obj));
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj->GetSptrRefCount() <= 0) {
|
||||
ZLOGE(LABEL, "Invalid stub object %{public}u.", ProcessSkeleton::ConvertAddr(obj));
|
||||
return;
|
||||
@ -739,7 +743,7 @@ int32_t BinderInvoker::GeneralServiceSendRequest(
|
||||
if ((refs != nullptr) && (tr.cookie) && (refs->AttemptIncStrongRef(this, count))) {
|
||||
auto *targetObject = reinterpret_cast<IPCObjectStub *>(tr.cookie);
|
||||
if (targetObject == nullptr) {
|
||||
ZLOGE(LABEL, "Invalid stub object %{public}u.", ProcessSkeleton::ConvertAddr(targetObject));
|
||||
ZLOGE(LABEL, "Invalid stub object");
|
||||
return error;
|
||||
}
|
||||
auto current = ProcessSkeleton::GetInstance();
|
||||
@ -994,6 +998,14 @@ int BinderInvoker::HandleCommands(uint32_t cmd)
|
||||
if (error != ERR_NONE) {
|
||||
if (ProcessSkeleton::IsPrint(error, lastErr_, lastErrCnt_)) {
|
||||
ZLOGE(LABEL, "HandleCommands cmd:%{public}u error:%{public}d", cmd, error);
|
||||
PrintParcelData(input_, "input_");
|
||||
PrintParcelData(output_, "output_");
|
||||
std::string backtrace;
|
||||
if (!GetBacktraceStringByTid(backtrace, gettid(), 0, false)) {
|
||||
ZLOGE(LABEL, "GetBacktraceStringByTid fail");
|
||||
} else {
|
||||
ZLOGW(LABEL, "backtrace info:\n%{public}s", backtrace.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cmd != BR_TRANSACTION) {
|
||||
@ -1047,6 +1059,7 @@ void BinderInvoker::UpdateConsumedData(const binder_write_read &bwr, const size_
|
||||
--sendNestCount_;
|
||||
if (sendNestCount_ > 0) {
|
||||
ZLOGW(LABEL, "unexpected sendNestCount:%{public}d", sendNestCount_.load());
|
||||
PrintParcelData(input_, "input_");
|
||||
PrintParcelData(output_, "output_");
|
||||
}
|
||||
output_.FlushBuffer();
|
||||
@ -1077,7 +1090,6 @@ int BinderInvoker::TransactWithDriver(bool doRead)
|
||||
bwr.read_buffer = input_.GetData();
|
||||
} else if (sendNestCount_ > 0 && input_.GetReadPosition() > 0 && input_.GetReadableBytes() > 0) {
|
||||
auto readSize = input_.GetReadableBytes();
|
||||
PrintParcelData(input_, "input_ before moving");
|
||||
Parcel temp;
|
||||
temp.WriteBuffer(reinterpret_cast<void *>(input_.GetData() + input_.GetReadPosition()), readSize);
|
||||
input_.RewindWrite(0);
|
||||
@ -1086,12 +1098,15 @@ int BinderInvoker::TransactWithDriver(bool doRead)
|
||||
input_.RewindRead(0);
|
||||
input_.RewindWrite(0);
|
||||
inputReservedSize_ = readSize;
|
||||
PrintParcelData(input_, "input_ after moving");
|
||||
bwr.read_size = input_.GetDataCapacity() - input_.GetDataSize();
|
||||
bwr.read_buffer = input_.GetData() + input_.GetDataSize();
|
||||
ZLOGI(LABEL, "read_size:%{public}llu read_buffer:%{public}llu readSize:%{public}zu inputSize:%{public}zu",
|
||||
bwr.read_size, bwr.read_buffer, readSize, input_.GetDataSize());
|
||||
} else {
|
||||
if (sendNestCount_ > 0) {
|
||||
bwr.write_size = 0;
|
||||
ZLOGW(LABEL, "input_ is full, delay to send request!");
|
||||
PrintParcelData(input_, "input_");
|
||||
PrintParcelData(output_, "output_");
|
||||
}
|
||||
bwr.read_size = 0;
|
||||
bwr.read_buffer = 0;
|
||||
}
|
||||
@ -1153,6 +1168,7 @@ bool BinderInvoker::WriteTransaction(int cmd, uint32_t flags, int32_t handle, ui
|
||||
|
||||
if (sendNestCount_ > 0) {
|
||||
ZLOGW(LABEL, "request nesting occurs, handle:%{public}d count:%{public}u", handle, sendNestCount_.load());
|
||||
PrintParcelData(input_, "input_");
|
||||
PrintParcelData(output_, "output_");
|
||||
std::string backtrace;
|
||||
if (!GetBacktraceStringByTid(backtrace, gettid(), 0, false)) {
|
||||
|
Loading…
Reference in New Issue
Block a user