Skip to content

Commit

Permalink
fixed object release error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wine93 authored and ilixiaocui committed Apr 14, 2021
1 parent 25de8e8 commit 769c123
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/chunkserver/chunkserver_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class CSCopysetMetric {
, copysetId_(0)
, chunkCount_(nullptr)
, snapshotCount_(nullptr)
, cloneChunkCount_(nullptr) {}
, cloneChunkCount_(nullptr)
, walSegmentCount_(nullptr) {}

~CSCopysetMetric() {}

Expand Down
4 changes: 1 addition & 3 deletions src/chunkserver/copyset_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ int CopysetNode::Init(const CopysetNodeOptions &options) {
metric_->MonitorCurveSegmentLogStorage(logStorage);
};

std::shared_ptr<LogStorageOptions> lsOptions =
std::make_shared<LogStorageOptions>(options.walFilePool,
monitorMetricCb);
LogStorageOptions lsOptions(options.walFilePool, monitorMetricCb);

// In order to get more copysetNode's information in CurveSegmentLogStorage
// without using global variables.
Expand Down
18 changes: 9 additions & 9 deletions src/chunkserver/raftlog/curve_segment_log_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
namespace curve {
namespace chunkserver {

std::shared_ptr<LogStorageOptions> StoreOptForCurveSegmentLogStorage(
std::shared_ptr<LogStorageOptions> options) {
static std::shared_ptr<LogStorageOptions> options_ = options;
if (nullptr != options) {
LogStorageOptions StoreOptForCurveSegmentLogStorage(
LogStorageOptions options) {
static LogStorageOptions options_;
if (nullptr != options.walFilePool) {
options_ = options;
}

Expand Down Expand Up @@ -678,14 +678,14 @@ void CurveSegmentLogStorage::sync() {

braft::LogStorage* CurveSegmentLogStorage::new_instance(
const std::string& uri) const {
std::shared_ptr<LogStorageOptions> options =
StoreOptForCurveSegmentLogStorage(nullptr);
LogStorageOptions options = StoreOptForCurveSegmentLogStorage(
LogStorageOptions());

CHECK(nullptr != options->walFilePool) << "wal file pool is null";
CHECK(nullptr != options.walFilePool) << "wal file pool is null";

CurveSegmentLogStorage* logStorage = new CurveSegmentLogStorage(
uri, true, options->walFilePool);
options->monitorMetricCb(logStorage);
uri, true, options.walFilePool);
options.monitorMetricCb(logStorage);

return logStorage;
}
Expand Down
5 changes: 3 additions & 2 deletions src/chunkserver/raftlog/curve_segment_log_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct LogStorageOptions {
std::shared_ptr<FilePool> walFilePool;
std::function<void(CurveSegmentLogStorage*)> monitorMetricCb;

LogStorageOptions() = default;
LogStorageOptions(std::shared_ptr<FilePool> walFilePool,
std::function<void(CurveSegmentLogStorage*)> monitorMetricCb)
: walFilePool(walFilePool), monitorMetricCb(monitorMetricCb) {
Expand All @@ -80,8 +81,8 @@ struct LogStorageStatus {
uint32_t walSegmentFileCount;
};

std::shared_ptr<LogStorageOptions> StoreOptForCurveSegmentLogStorage(
std::shared_ptr<LogStorageOptions> options);
LogStorageOptions StoreOptForCurveSegmentLogStorage(
LogStorageOptions options);

void RegisterCurveSegmentLogStorageOrDie();

Expand Down
2 changes: 0 additions & 2 deletions src/chunkserver/trash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,5 +331,3 @@ uint32_t Trash::CountChunkNumInCopyset(const std::string &copysetPath) {

} // namespace chunkserver
} // namespace curve


0 comments on commit 769c123

Please sign in to comment.