From 5749ddf33dc012d856e1438ffe54bfe25852c8d0 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 4 Aug 2020 22:48:23 +0300 Subject: [PATCH] Minor fixes. GitOrigin-RevId: 6d9a609ab9c773d1e4f3fe81f84947e142e15f35 --- tddb/td/db/binlog/Binlog.cpp | 6 +++--- tdutils/td/utils/buffer.cpp | 3 +-- tdutils/td/utils/buffer.h | 2 ++ test/tqueue.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index 88ac4408a..5d4c526be 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -667,9 +667,9 @@ void Binlog::do_reindex() { << fd_size_ << ' ' << detail::file_size(path_) << ' ' << fd_events_ << ' ' << path_; double ratio = static_cast(start_size) / static_cast(finish_size + 1); - LOG(ERROR) << "Regenerate index " << tag("name", path_) << tag("time", format::as_time(finish_time - start_time)) - << tag("before_size", format::as_size(start_size)) << tag("after_size", format::as_size(finish_size)) - << tag("ratio", ratio) << tag("before_events", start_events) << tag("after_events", finish_events); + LOG(INFO) << "Regenerate index " << tag("name", path_) << tag("time", format::as_time(finish_time - start_time)) + << tag("before_size", format::as_size(start_size)) << tag("after_size", format::as_size(finish_size)) + << tag("ratio", ratio) << tag("before_events", start_events) << tag("after_events", finish_events); buffer_writer_ = ChainBufferWriter(); buffer_reader_ = buffer_writer_.extract_reader(); diff --git a/tdutils/td/utils/buffer.cpp b/tdutils/td/utils/buffer.cpp index cba6fbddf..4d08d5dbe 100644 --- a/tdutils/td/utils/buffer.cpp +++ b/tdutils/td/utils/buffer.cpp @@ -7,7 +7,6 @@ #include "td/utils/buffer.h" #include "td/utils/port/thread_local.h" - #include "td/utils/ThreadSafeCounter.h" #include @@ -26,7 +25,7 @@ TD_THREAD_LOCAL BufferAllocator::BufferRawTls *BufferAllocator::buffer_raw_tls; std::atomic BufferAllocator::buffer_mem; -static td::ThreadSafeCounter buffer_slice_size_; +static ThreadSafeCounter buffer_slice_size_; int64 BufferAllocator::get_buffer_slice_size() { return buffer_slice_size_.sum(); diff --git a/tdutils/td/utils/buffer.h b/tdutils/td/utils/buffer.h index 8d1eb2e24..401c2bac0 100644 --- a/tdutils/td/utils/buffer.h +++ b/tdutils/td/utils/buffer.h @@ -116,6 +116,8 @@ class BufferSlice { : buffer_(std::move(buffer_ptr)), begin_(begin), end_(end) { debug_track(); } + BufferSlice(const BufferSlice &other) = delete; + BufferSlice &operator=(const BufferSlice &other) = delete; BufferSlice(BufferSlice &&other) : BufferSlice(std::move(other.buffer_), other.begin_, other.end_) { debug_untrack(); // yes, debug_untrack } diff --git a/test/tqueue.cpp b/test/tqueue.cpp index 812eeb1cc..6122daf55 100644 --- a/test/tqueue.cpp +++ b/test/tqueue.cpp @@ -9,11 +9,11 @@ #include "td/db/binlog/BinlogHelper.h" #include "td/db/TQueue.h" -#include "td/utils/Random.h" #include "td/utils/buffer.h" #include "td/utils/int_types.h" #include "td/utils/misc.h" #include "td/utils/port/path.h" +#include "td/utils/Random.h" #include "td/utils/Slice.h" #include "td/utils/Span.h" #include "td/utils/Status.h" @@ -196,7 +196,7 @@ TEST(TQueue, random) { } TEST(TQueue, memory_leak) { - //return; + return; auto tqueue = td::TQueue::create(); auto tqueue_binlog = td::make_unique>(); std::string binlog_path = "test_tqueue.binlog"; @@ -213,8 +213,8 @@ TEST(TQueue, memory_leak) { while (true) { auto id = tqueue->push(1, "a", now + 600000, 0, {}).move_as_ok(); ids.push_back(id); - if (ids.size() > rnd() % 100000) { - auto it = rnd() % ids.size(); + if (ids.size() > static_cast(rnd()) % 100000) { + auto it = static_cast(rnd()) % ids.size(); std::swap(ids.back(), ids[it]); tqueue->forget(1, ids.back()); ids.pop_back();