mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-19 17:43:35 -04:00
!45 修复dinput safuzz 4809 61441接口crash
Merge pull request !45 from joe/master
This commit is contained in:
@@ -18,7 +18,9 @@
|
||||
|
||||
#include "i_distributed_source_input.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
|
||||
#include "iremote_stub.h"
|
||||
|
||||
@@ -57,6 +59,9 @@ private:
|
||||
int32_t HandleRegisterSimulationEventListener(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleUnregisterSimulationEventListener(MessageParcel &data, MessageParcel &reply);
|
||||
DISALLOW_COPY_AND_MOVE(DistributedInputSourceStub);
|
||||
private:
|
||||
std::atomic<bool> sourceManagerInitFlag_ {false};
|
||||
std::mutex operatorMutex_;
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -31,21 +31,33 @@ DistributedInputSourceStub::~DistributedInputSourceStub()
|
||||
|
||||
int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel &reply)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(operatorMutex_);
|
||||
if (sourceManagerInitFlag_.load()) {
|
||||
DHLOGE("DistributedInputSourceStub already init.");
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
int32_t ret = Init();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
DHLOGE("DistributedInputSourceStub Init write ret failed");
|
||||
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
|
||||
}
|
||||
sourceManagerInitFlag_.store(true);
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParcel &reply)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(operatorMutex_);
|
||||
if (!sourceManagerInitFlag_.load()) {
|
||||
DHLOGE("DistributedInputSourceStub already Release.");
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
int32_t ret = Release();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
DHLOGE("DistributedInputSourceStub release write ret failed");
|
||||
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
|
||||
}
|
||||
sourceManagerInitFlag_.store(false);
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user