mirror of
https://gitee.com/openharmony/distributeddatamgr_datamgr_service
synced 2024-11-30 18:40:59 +00:00
fix:force close before unwatch
Signed-off-by: htt1997 <hutao105@huawei.com>
This commit is contained in:
parent
54b97ea30f
commit
58a2c6130a
@ -147,7 +147,7 @@ public:
|
||||
|
||||
virtual int32_t UnregisterDetailProgressObserver() = 0;
|
||||
|
||||
virtual int32_t Close() = 0;
|
||||
virtual int32_t Close(bool isForce = false) = 0;
|
||||
|
||||
virtual int32_t AddRef() = 0;
|
||||
|
||||
|
@ -42,7 +42,7 @@ void AutoCache::Bind(std::shared_ptr<Executor> executor)
|
||||
if (executor == nullptr || taskId_ != Executor::INVALID_TASK_ID) {
|
||||
return;
|
||||
}
|
||||
executor_ = executor;
|
||||
executor_ = std::move(executor);
|
||||
}
|
||||
|
||||
AutoCache::AutoCache()
|
||||
@ -226,8 +226,8 @@ AutoCache::Delegate::Delegate(GeneralStore *delegate, const Watchers &watchers,
|
||||
AutoCache::Delegate::~Delegate()
|
||||
{
|
||||
if (store_ != nullptr) {
|
||||
store_->Close(true);
|
||||
store_->Unwatch(Origin::ORIGIN_ALL, *this);
|
||||
store_->Close();
|
||||
store_->Release();
|
||||
store_ = nullptr;
|
||||
}
|
||||
|
@ -241,14 +241,13 @@ bool KVDBGeneralStore::IsBound()
|
||||
return isBound_;
|
||||
}
|
||||
|
||||
int32_t KVDBGeneralStore::Close()
|
||||
int32_t KVDBGeneralStore::Close(bool isForce)
|
||||
{
|
||||
std::unique_lock<decltype(rwMutex_)> lock(rwMutex_);
|
||||
if (delegate_ == nullptr) {
|
||||
return GeneralError::E_OK;
|
||||
}
|
||||
int32_t count = delegate_->GetTaskCount();
|
||||
if (count > 0) {
|
||||
if (!isForce && delegate_->GetTaskCount() > 0) {
|
||||
return GeneralError::E_BUSY;
|
||||
}
|
||||
if (delegate_ != nullptr) {
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
int32_t Unwatch(int32_t origin, Watcher &watcher) override;
|
||||
int32_t RegisterDetailProgressObserver(DetailAsync async) override;
|
||||
int32_t UnregisterDetailProgressObserver() override;
|
||||
int32_t Close() override;
|
||||
int32_t Close(bool isForce = false) override;
|
||||
int32_t AddRef() override;
|
||||
int32_t Release() override;
|
||||
int32_t BindSnapshots(std::shared_ptr<std::map<std::string, std::shared_ptr<Snapshot>>> bindAssets) override;
|
||||
|
@ -204,14 +204,13 @@ bool RdbGeneralStore::IsBound()
|
||||
return isBound_;
|
||||
}
|
||||
|
||||
int32_t RdbGeneralStore::Close()
|
||||
int32_t RdbGeneralStore::Close(bool isForce)
|
||||
{
|
||||
std::unique_lock<decltype(rwMutex_)> lock(rwMutex_);
|
||||
if (delegate_ == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
int32_t count = delegate_->GetCloudSyncTaskCount();
|
||||
if (count > 0) {
|
||||
if (!isForce && delegate_->GetCloudSyncTaskCount() > 0) {
|
||||
return GeneralError::E_BUSY;
|
||||
}
|
||||
auto status = manager_.CloseStore(delegate_);
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
int32_t Unwatch(int32_t origin, Watcher &watcher) override;
|
||||
int32_t RegisterDetailProgressObserver(DetailAsync async) override;
|
||||
int32_t UnregisterDetailProgressObserver() override;
|
||||
int32_t Close() override;
|
||||
int32_t Close(bool isForce = false) override;
|
||||
int32_t AddRef() override;
|
||||
int32_t Release() override;
|
||||
int32_t BindSnapshots(std::shared_ptr<std::map<std::string, std::shared_ptr<Snapshot>>> bindAssets) override;
|
||||
|
@ -62,7 +62,7 @@ int32_t RdbNotifierProxy::OnChange(const Origin &origin, const PrimaryFields &pr
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (Remote()->SendRequest(
|
||||
static_cast<uint32_t>(NotifierIFCode::RDB_NOTIFIER_CMD_DATA_CHANGE), data, reply, option) != 0) {
|
||||
ZLOGE("storeName:%{public}s, send request failed", DistributedData::Anonymous::Change(origin.store).c_str());
|
||||
|
@ -104,7 +104,7 @@ int32_t GeneralStoreMock::UnregisterDetailProgressObserver()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GeneralStoreMock::Close()
|
||||
int32_t GeneralStoreMock::Close(bool isForce)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
int32_t Unwatch(int32_t origin, Watcher &watcher) override;
|
||||
int32_t RegisterDetailProgressObserver(DetailAsync async) override;
|
||||
int32_t UnregisterDetailProgressObserver() override;
|
||||
int32_t Close() override;
|
||||
int32_t Close(bool isForce) override;
|
||||
int32_t AddRef() override;
|
||||
int32_t Release() override;
|
||||
int32_t BindSnapshots(std::shared_ptr<std::map<std::string, std::shared_ptr<Snapshot>>> bindAssets) override;
|
||||
|
Loading…
Reference in New Issue
Block a user