Various fixes.

GitOrigin-RevId: 94d0df55495a08b5599c90f56dbe08ac3a3d65e5
This commit is contained in:
levlam 2019-08-14 03:13:34 +03:00
parent bb24ec0629
commit 84695437d3
24 changed files with 49 additions and 25 deletions

View File

@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/Client.h"
#include "td/telegram/td_api.h"
#include "td/utils/common.h"
#include "td/utils/logging.h"

View File

@ -1633,7 +1633,7 @@ callStateError error:error = CallState;
//@class CallProblem @description Describes a type of a problem that happened during a call
//@description The user heard his own voice
//@description The user heard their own voice
callProblemEcho = CallProblem;
//@description The user heard background noice

View File

@ -10,7 +10,6 @@
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/UInt.h"
#include <utility>

View File

@ -12,11 +12,9 @@
#include "td/tl/tl_json.h"
#include "td/utils/common.h"
#include "td/utils/format.h"
#include "td/utils/JsonBuilder.h"
#include "td/utils/logging.h"
#include "td/utils/port/thread_local.h"
#include "td/utils/Status.h"
#include <utility>

View File

@ -19,6 +19,7 @@
#include "td/telegram/SetWithPosition.h"
#include "td/telegram/UserId.h"
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"

View File

@ -69,6 +69,7 @@
#include "td/utils/misc.h"
#include "td/utils/PathView.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/utf8.h"
#include <algorithm>
#include <utility>

View File

@ -11,6 +11,7 @@
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/Random.h"
#include "td/utils/SharedSlice.h"
namespace td {
namespace secure_storage {

View File

@ -6,8 +6,6 @@
//
#include "td/telegram/SendCodeHelper.h"
#include "td/utils/utf8.h"
namespace td {
void SendCodeHelper::on_sent_code(telegram_api::object_ptr<telegram_api::auth_sentCode> sent_code) {

View File

@ -263,20 +263,22 @@ void StorageManager::hangup_shared() {
}
void StorageManager::close_stats_worker() {
for (auto &promise : pending_storage_stats_) {
auto promises = std::move(pending_storage_stats_);
pending_storage_stats_.clear();
for (auto &promise : promises) {
promise.set_error(Status::Error(500, "Request aborted"));
}
pending_storage_stats_.clear();
stats_generation_++;
stats_worker_.reset();
stats_cancellation_token_source_.cancel();
}
void StorageManager::close_gc_worker() {
for (auto &promise : pending_run_gc_) {
auto promises = std::move(pending_run_gc_);
pending_run_gc_.clear();
for (auto &promise : promises) {
promise.set_error(Status::Error(500, "Request aborted"));
}
pending_run_gc_.clear();
gc_generation_++;
gc_worker_.reset();
gc_cancellation_token_source_.cancel();

View File

@ -61,6 +61,7 @@
#include "td/telegram/Payments.h"
#include "td/telegram/PhoneNumberManager.h"
#include "td/telegram/Photo.h"
#include "td/telegram/PhotoSizeSource.h"
#include "td/telegram/PollManager.h"
#include "td/telegram/PrivacyManager.h"
#include "td/telegram/RequestActor.h"

View File

@ -27,7 +27,6 @@
#include "td/utils/port/path.h"
#include "td/utils/port/Stat.h"
#include "td/utils/ScopeGuard.h"
#include "td/utils/Slice.h"
#include "td/utils/UInt.h"
#include <tuple>

View File

@ -20,6 +20,7 @@
#include "td/telegram/files/FileStats.h"
#include "td/telegram/files/FileType.h"
#include "td/telegram/Location.h"
#include "td/telegram/PhotoSizeSource.h"
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"

View File

@ -15,6 +15,8 @@
#include "td/utils/common.h"
#include "td/utils/Status.h"
#include "td/utils/Time.h"
#include "td/utils/tl_helpers.h"
namespace td {

View File

@ -12,9 +12,11 @@
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/Random.h"
#include "td/utils/ScopeGuard.h"
#include <limits>
#include <map>
#include <memory>
#include <utility>
using namespace td;
@ -493,7 +495,7 @@ class WithXContext : public Actor {
}
};
void check_context() {
static void check_context() {
auto ptr = static_cast<XContext *>(Scheduler::context());
CHECK(ptr);
ptr->validate();

View File

@ -6,10 +6,13 @@
//
#pragma once
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include <atomic>
#include <memory>
#include <new>
#include <type_traits>
namespace td {
@ -134,7 +137,7 @@ class UnsafeSharedSlice {
return reinterpret_cast<HeaderT *>(ptr_.get());
}
struct Destructor {
struct SharedSliceDestructor {
void operator()(char *ptr) {
auto header = reinterpret_cast<HeaderT *>(ptr);
if (header->dec()) {
@ -146,7 +149,7 @@ class UnsafeSharedSlice {
}
};
std::unique_ptr<char[], Destructor> ptr_;
std::unique_ptr<char[], SharedSliceDestructor> ptr_;
};
} // namespace detail

View File

@ -6,6 +6,7 @@
//
#pragma once
#include "td/utils/common.h"
#include "td/utils/port/thread_local.h"
#include <array>
@ -16,19 +17,19 @@ namespace td {
template <class T>
class ThreadLocalStorage {
public:
T& get() {
T &get() {
return thread_local_node().value;
}
template <class F>
void for_each(F&& f) {
void for_each(F &&f) {
int32 n = max_thread_id_.load();
for (int32 i = 0; i < n; i++) {
f(nodes_[i].value);
}
}
template <class F>
void for_each(F&& f) const {
void for_each(F &&f) const {
int32 n = max_thread_id_.load();
for (int32 i = 0; i < n; i++) {
f(nodes_[i].value);
@ -44,7 +45,7 @@ class ThreadLocalStorage {
std::atomic<int32> max_thread_id_{MAX_THREAD_ID};
std::array<Node, MAX_THREAD_ID> nodes_;
Node& thread_local_node() {
Node &thread_local_node() {
auto thread_id = get_thread_id();
CHECK(0 <= thread_id && static_cast<size_t>(thread_id) < nodes_.size());
return nodes_[thread_id];

View File

@ -6,10 +6,13 @@
//
#pragma once
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/ThreadLocalStorage.h"
#include <array>
#include <atomic>
#include <mutex>
namespace td {

View File

@ -6,9 +6,14 @@
//
#include "td/utils/TsFileLog.h"
#include "td/utils/common.h"
#include "td/utils/FileLog.h"
#include "td/utils/logging.h"
#include "td/utils/port/thread_local.h"
#include "td/utils/Slice.h"
#include <array>
#include <limits>
namespace td {

View File

@ -7,7 +7,6 @@
#pragma once
#include "td/utils/common.h"
#include "td/utils/FileLog.h"
#include "td/utils/logging.h"
#include "td/utils/Status.h"

View File

@ -9,8 +9,6 @@
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include <cstring>
namespace td {
template <size_t size>
@ -57,8 +55,8 @@ bool operator!=(const UInt<size> &a, const UInt<size> &b) {
}
template <size_t size>
td::UInt<size> operator^(const UInt<size> &a, const UInt<size> &b) {
td::UInt<size> res;
UInt<size> operator^(const UInt<size> &a, const UInt<size> &b) {
UInt<size> res;
for (size_t i = 0; i < size / 8; i++) {
res.raw[i] = static_cast<uint8>(a.raw[i] ^ b.raw[i]);
}

View File

@ -7,7 +7,6 @@
#include "td/utils/base64.h"
#include "td/utils/common.h"
#include "td/utils/format.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"

View File

@ -4,6 +4,8 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/utils/common.h"
#include "td/utils/port/thread.h"
#include "td/utils/SharedSlice.h"
#include "td/utils/tests.h"

View File

@ -6,11 +6,17 @@
//
#include "td/utils/benchmark.h"
#include "td/utils/FileLog.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/port/path.h"
#include "td/utils/port/thread.h"
#include "td/utils/Slice.h"
#include "td/utils/tests.h"
#include "td/utils/TsFileLog.h"
#include <functional>
#include <limits>
// Thread safe logging with tests
//
// LOG uses thread local LogInterface
@ -60,7 +66,7 @@ class LogBenchmark : public td::Benchmark {
};
template <class F>
void bench_log(std::string name, int threads_n, F &&f) {
static void bench_log(std::string name, int threads_n, F &&f) {
bench(LogBenchmark<typename decltype(f())::element_type>(std::move(name), threads_n, std::move(f)));
};

View File

@ -16,6 +16,8 @@
#include "td/utils/Slice.h"
#include "td/utils/tests.h"
#include <set>
using namespace td;
TEST(Port, files) {