Various fixes.

GitOrigin-RevId: da4869e5054952663ad5993f5770f2984a473818
This commit is contained in:
levlam 2019-07-22 07:01:51 +03:00
parent 8853c37fe2
commit 20503e04d2
14 changed files with 32 additions and 26 deletions

3
.gitattributes vendored
View File

@ -29,9 +29,6 @@
*.csproj text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent
*.sln text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent
*.xml text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent
*.rb text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent
*.lock text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent
*.go text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent
*.config text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent
sqlite/sqlite/* linguist-vendored

View File

@ -1187,7 +1187,8 @@ void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_
if (photo.id == -2 || photo.id == 0) {
LOG(ERROR) << "Receive empty photo in web page instant view for " << web_page->url;
} else {
photos.emplace(photo.id, std::move(photo));
auto photo_id = photo.id;
photos.emplace(photo_id, std::move(photo));
}
}
if (web_page->photo.id != -2 && web_page->photo.id != 0) {

View File

@ -51,7 +51,7 @@ target_include_directories(tdnet SYSTEM PRIVATE $<BUILD_INTERFACE:${OPENSSL_INCL
target_link_libraries(tdnet PUBLIC tdutils tdactor PRIVATE ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
target_link_libraries(tdnet PRIVATE ${OPENSSL_CRYPTO_LIBRARY})
if (NOT EMSCRIPTEN)
target_link_libraries(tdnet PRIVATE ${OPENSSL_SSL_LIBRARY})
target_link_libraries(tdnet PRIVATE ${OPENSSL_SSL_LIBRARY})
endif()
if (WIN32)

View File

@ -542,12 +542,15 @@ size_t SslStream::flow_write(Slice slice) {
}
} // namespace td
#else
namespace td {
namespace detail {
class SslStreamImpl {
};
}
class SslStreamImpl {};
} // namespace detail
SslStream::SslStream() = default;
SslStream::SslStream(SslStream &&) = default;
SslStream &SslStream::operator=(SslStream &&) = default;
@ -556,20 +559,26 @@ SslStream::~SslStream() = default;
Result<SslStream> SslStream::create(CSlice host, CSlice cert_file, VerifyPeer verify_peer) {
return Status::Error("Not supported in emscripten");
}
SslStream::SslStream(unique_ptr<detail::SslStreamImpl> impl) : impl_(std::move(impl)) {
}
ByteFlowInterface &SslStream::read_byte_flow() {
UNREACHABLE();
}
ByteFlowInterface &SslStream::write_byte_flow() {
UNREACHABLE();
}
size_t SslStream::flow_read(MutableSlice slice) {
UNREACHABLE();
}
size_t SslStream::flow_write(Slice slice) {
UNREACHABLE();
}
} // namespace td
#endif

View File

@ -14,7 +14,7 @@ namespace td {
namespace detail {
class SslStreamImpl;
}
} // namespace detail
class SslStream {
public:

View File

@ -238,7 +238,7 @@ class ConcurrentHashMap {
TaskCreator task_creator;
void do_migrate(HashMap *ptr) {
//LOG(ERROR) << "do migrate: " << ptr;
//LOG(ERROR) << "In do_migrate: " << ptr;
std::unique_lock<std::mutex> lock(migrate_mutex_);
if (hash_map_.load() != ptr) {
return;
@ -260,7 +260,7 @@ class ConcurrentHashMap {
}
void finish_migrate() {
//LOG(ERROR) << "finish_migrate";
//LOG(ERROR) << "In finish_migrate";
hash_map_.store(migrate_to_hash_map_);
hp_.retire(get_thread_id(), migrate_from_hash_map_);
migrate_from_hash_map_ = nullptr;
@ -273,7 +273,7 @@ class ConcurrentHashMap {
if (migrate_from_hash_map_ != nullptr) {
return;
}
//LOG(ERROR) << "init_migrate";
//LOG(ERROR) << "In init_migrate";
CHECK(migrate_cnt_ == 0);
migrate_generation_++;
migrate_from_hash_map_ = hash_map_.exchange(nullptr);
@ -285,7 +285,7 @@ class ConcurrentHashMap {
}
void run_migrate() {
//LOG(ERROR) << "run_migrate";
//LOG(ERROR) << "In run_migrate";
size_t cnt = 0;
while (true) {
auto task = task_creator.create();
@ -295,7 +295,7 @@ class ConcurrentHashMap {
}
run_task(task);
}
//LOG(ERROR) << "run_migrate " << cnt;
//LOG(ERROR) << "In run_migrate " << cnt;
}
void run_task(Task task) {
@ -309,7 +309,7 @@ class ConcurrentHashMap {
//LOG(ERROR) << node_key << " " << node_key;
auto ok = migrate_to_hash_map_->with_value(
node_key, true, [&](auto &node_value) { node_value.store(old_value, std::memory_order_relaxed); });
LOG_CHECK(ok) << "migration overflow";
LOG_CHECK(ok) << "Migration overflow";
}
}
};

View File

@ -197,7 +197,7 @@ Result<FileFd> FileFd::open(CSlice filepath, int32 flags, int32 mode) {
CreateFile(w_filepath.c_str(), desired_access, share_mode, nullptr, creation_disposition, native_flags, nullptr);
#else
CREATEFILE2_EXTENDED_PARAMETERS extended_parameters;
memset(&extended_parameters, 0, sizeof(extended_parameters));
std::memset(&extended_parameters, 0, sizeof(extended_parameters));
extended_parameters.dwFileFlags = native_flags;
auto handle = CreateFile2(w_filepath.c_str(), desired_access, share_mode, creation_disposition, &extended_parameters);
#endif

View File

@ -56,7 +56,7 @@ class IocpRef {
IocpRef(IocpRef &&) = default;
IocpRef &operator=(IocpRef &&) = default;
IocpRef(std::weak_ptr<NativeFd> iocp_handle);
explicit IocpRef(std::weak_ptr<NativeFd> iocp_handle);
bool post(size_t size, Iocp::Callback *callback, WSAOVERLAPPED *overlapped);

View File

@ -316,7 +316,7 @@ static void default_failure_signal_handler(int sig) {
}
Status set_default_failure_signal_handler() {
atexit(block_stdin);
std::atexit(block_stdin);
TRY_STATUS(setup_signals_alt_stack());
TRY_STATUS(set_signal_handler(SignalType::Abort, default_failure_signal_handler));
TRY_STATUS(set_signal_handler(SignalType::Error, default_failure_signal_handler));

View File

@ -82,7 +82,7 @@ void print_backtrace_gdb(void) {
#endif
dup2(2, 1); // redirect output to stderr
execlp("gdb", "gdb", "--batch", "-n", "-ex", "thread", "-ex", "thread apply all bt full", name_buf, pid_buf_begin,
NULL);
nullptr);
return;
} else {
#if TD_LINUX && defined(PR_SET_PTRACER)

View File

@ -43,7 +43,7 @@ class ArrayHashMap {
}
struct Node {
std::atomic<KeyT> key{KeyT{}};
std::atomic<ValueT> value{};
std::atomic<ValueT> value{ValueT{}};
};
static std::string get_name() {
return "ArrayHashMap";
@ -188,7 +188,7 @@ class HashMapBenchmark : public td::Benchmark {
size_t threads_n = 16;
int mod_;
constexpr static size_t mul_ = 7273; //1000000000 + 7;
static constexpr size_t mul_ = 7273; //1000000000 + 7;
int n_;
public:
@ -235,7 +235,7 @@ class HashMapBenchmark : public td::Benchmark {
};
template <class HashMap>
void bench_hash_map() {
static void bench_hash_map() {
td::bench(HashMapBenchmark<HashMap>(16));
td::bench(HashMapBenchmark<HashMap>(1));
}

View File

@ -15,7 +15,7 @@
#if !TD_THREAD_UNSUPPORTED
TEST(EpochBaseMemoryReclamation, stress) {
struct Node {
std::atomic<std::string *> name_;
std::atomic<std::string *> name_{nullptr};
char pad[64];
};

View File

@ -872,7 +872,7 @@ class ValueB {
};
template <template <class T> class HashT>
void test_hash() {
static void test_hash() {
// Just check that the following compiles
AbslHashValue(Hasher(), ValueA{1});
HashT<ValueA>()(ValueA{1});

View File

@ -629,7 +629,6 @@ TEST(Mtproto, TlsTransport) {
{
auto guard = sched.get_main_guard();
class RunTest : public Actor {
private:
void start_up() override {
class Callback : public TransparentProxy::Callback {
public: