Update clag-format to the latest (190926/r372920) version.
GitOrigin-RevId: 7861ae8ad28eb1f6a06ff3c6f56eff3f67b1d24c
This commit is contained in:
parent
c7811a01b6
commit
0b6c1d226f
@ -3,16 +3,20 @@ Language: Cpp
|
|||||||
# BasedOnStyle: Google
|
# BasedOnStyle: Google
|
||||||
AccessModifierOffset: -1
|
AccessModifierOffset: -1
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveMacros: false
|
||||||
AlignConsecutiveAssignments: false
|
AlignConsecutiveAssignments: false
|
||||||
AlignConsecutiveDeclarations: false
|
AlignConsecutiveDeclarations: false
|
||||||
AlignEscapedNewlines: Left
|
AlignEscapedNewlines: Left
|
||||||
AlignOperands: true
|
AlignOperands: true
|
||||||
AlignTrailingComments: true
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
AllowShortBlocksOnASingleLine: false
|
AllowShortBlocksOnASingleLine: Never
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
AllowShortFunctionsOnASingleLine: None # All
|
AllowShortFunctionsOnASingleLine: None # All
|
||||||
AllowShortIfStatementsOnASingleLine: false # true
|
AllowShortIfStatementsOnASingleLine: Never # WithoutElse
|
||||||
|
AllowShortLambdasOnASingleLine: Inline # All
|
||||||
AllowShortLoopsOnASingleLine: false # true
|
AllowShortLoopsOnASingleLine: false # true
|
||||||
AlwaysBreakAfterDefinitionReturnType: None
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: None
|
||||||
@ -21,6 +25,7 @@ AlwaysBreakTemplateDeclarations: Yes
|
|||||||
BinPackArguments: true
|
BinPackArguments: true
|
||||||
BinPackParameters: true
|
BinPackParameters: true
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
AfterClass: false
|
AfterClass: false
|
||||||
AfterControlStatement: false
|
AfterControlStatement: false
|
||||||
AfterEnum: false
|
AfterEnum: false
|
||||||
@ -60,6 +65,7 @@ ForEachMacros:
|
|||||||
- Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY
|
- Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY
|
||||||
IncludeBlocks: Preserve
|
IncludeBlocks: Preserve
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
|
IndentGotoLabels: true
|
||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
IndentWidth: 2
|
IndentWidth: 2
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
@ -87,6 +93,7 @@ ReflowComments: false # true
|
|||||||
SortIncludes: false # disabled, because we need case insensitive sort
|
SortIncludes: false # disabled, because we need case insensitive sort
|
||||||
SortUsingDeclarations: false # true
|
SortUsingDeclarations: false # true
|
||||||
SpaceAfterCStyleCast: false
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
SpaceAfterTemplateKeyword: true
|
SpaceAfterTemplateKeyword: true
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
SpaceBeforeCpp11BracedList: false
|
SpaceBeforeCpp11BracedList: false
|
||||||
@ -94,6 +101,7 @@ SpaceBeforeCtorInitializerColon: true
|
|||||||
SpaceBeforeInheritanceColon: true
|
SpaceBeforeInheritanceColon: true
|
||||||
SpaceBeforeParens: ControlStatements
|
SpaceBeforeParens: ControlStatements
|
||||||
SpaceBeforeRangeBasedForLoopColon: true
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
SpaceInEmptyParentheses: false
|
SpaceInEmptyParentheses: false
|
||||||
SpacesBeforeTrailingComments: 2
|
SpacesBeforeTrailingComments: 2
|
||||||
SpacesInAngles: false
|
SpacesInAngles: false
|
||||||
|
@ -222,15 +222,13 @@ class CreateFileBench : public Benchmark {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void tear_down() override {
|
void tear_down() override {
|
||||||
td::walk_path("A/",
|
td::walk_path("A/", [&](CSlice path, auto type) {
|
||||||
[&](CSlice path, auto type) {
|
|
||||||
if (type == td::WalkPath::Type::ExitDir) {
|
if (type == td::WalkPath::Type::ExitDir) {
|
||||||
rmdir(path).ignore();
|
rmdir(path).ignore();
|
||||||
} else if (type == td::WalkPath::Type::NotDir) {
|
} else if (type == td::WalkPath::Type::NotDir) {
|
||||||
unlink(path).ignore();
|
unlink(path).ignore();
|
||||||
}
|
}
|
||||||
})
|
}).ignore();
|
||||||
.ignore();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -246,26 +244,22 @@ class WalkPathBench : public Benchmark {
|
|||||||
}
|
}
|
||||||
void run(int n) override {
|
void run(int n) override {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
td::walk_path("A/",
|
td::walk_path("A/", [&](CSlice path, auto type) {
|
||||||
[&](CSlice path, auto type) {
|
|
||||||
if (type == td::WalkPath::Type::EnterDir) {
|
if (type == td::WalkPath::Type::EnterDir) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stat(path).ok();
|
stat(path).ok();
|
||||||
cnt++;
|
cnt++;
|
||||||
})
|
}).ignore();
|
||||||
.ignore();
|
|
||||||
}
|
}
|
||||||
void tear_down() override {
|
void tear_down() override {
|
||||||
td::walk_path("A/",
|
td::walk_path("A/", [&](CSlice path, auto type) {
|
||||||
[&](CSlice path, auto type) {
|
|
||||||
if (type == td::WalkPath::Type::ExitDir) {
|
if (type == td::WalkPath::Type::ExitDir) {
|
||||||
rmdir(path).ignore();
|
rmdir(path).ignore();
|
||||||
} else if (type == td::WalkPath::Type::NotDir) {
|
} else if (type == td::WalkPath::Type::NotDir) {
|
||||||
unlink(path).ignore();
|
unlink(path).ignore();
|
||||||
}
|
}
|
||||||
})
|
}).ignore();
|
||||||
.ignore();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,7 +53,9 @@ td::Result<TlsInfo> test_tls(const td::string &url) {
|
|||||||
|
|
||||||
td::string request;
|
td::string request;
|
||||||
|
|
||||||
auto add_string = [&](td::Slice data) { request.append(data.data(), data.size()); };
|
auto add_string = [&](td::Slice data) {
|
||||||
|
request.append(data.data(), data.size());
|
||||||
|
};
|
||||||
auto add_random = [&](size_t length) {
|
auto add_random = [&](size_t length) {
|
||||||
while (length-- > 0) {
|
while (length-- > 0) {
|
||||||
request += static_cast<char>(td::Random::secure_int32());
|
request += static_cast<char>(td::Random::secure_int32());
|
||||||
|
@ -202,7 +202,9 @@ class SessionConnection
|
|||||||
auto set_buffer_slice(BufferSlice *buffer_slice) TD_WARN_UNUSED_RESULT {
|
auto set_buffer_slice(BufferSlice *buffer_slice) TD_WARN_UNUSED_RESULT {
|
||||||
auto old_buffer_slice = current_buffer_slice_;
|
auto old_buffer_slice = current_buffer_slice_;
|
||||||
current_buffer_slice_ = buffer_slice;
|
current_buffer_slice_ = buffer_slice;
|
||||||
return ScopeExit() + [&to = current_buffer_slice_, from = old_buffer_slice] { to = from; };
|
return ScopeExit() + [&to = current_buffer_slice_, from = old_buffer_slice] {
|
||||||
|
to = from;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Status parse_message(TlParser &parser, MsgInfo *info, Slice *packet, bool crypto_flag = true) TD_WARN_UNUSED_RESULT;
|
Status parse_message(TlParser &parser, MsgInfo *info, Slice *packet, bool crypto_flag = true) TD_WARN_UNUSED_RESULT;
|
||||||
|
@ -987,7 +987,9 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
|
|||||||
shared_config.set_option_string("photo_search_bot_username", config->img_search_username_);
|
shared_config.set_option_string("photo_search_bot_username", config->img_search_username_);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fix_timeout_ms = [](int32 timeout_ms) { return clamp(timeout_ms, 1000, 86400 * 1000); };
|
auto fix_timeout_ms = [](int32 timeout_ms) {
|
||||||
|
return clamp(timeout_ms, 1000, 86400 * 1000);
|
||||||
|
};
|
||||||
|
|
||||||
shared_config.set_option_integer("online_update_period_ms", fix_timeout_ms(config->online_update_period_ms_));
|
shared_config.set_option_integer("online_update_period_ms", fix_timeout_ms(config->online_update_period_ms_));
|
||||||
|
|
||||||
|
@ -27065,13 +27065,17 @@ void MessagesManager::suffix_load_add_query(Dialog *d,
|
|||||||
|
|
||||||
void MessagesManager::suffix_load_till_date(Dialog *d, int32 date, Promise<> promise) {
|
void MessagesManager::suffix_load_till_date(Dialog *d, int32 date, Promise<> promise) {
|
||||||
LOG(INFO) << "Load suffix of " << d->dialog_id << " till date " << date;
|
LOG(INFO) << "Load suffix of " << d->dialog_id << " till date " << date;
|
||||||
auto condition = [date](const Message *m) { return m != nullptr && m->date < date; };
|
auto condition = [date](const Message *m) {
|
||||||
|
return m != nullptr && m->date < date;
|
||||||
|
};
|
||||||
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
|
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::suffix_load_till_message_id(Dialog *d, MessageId message_id, Promise<> promise) {
|
void MessagesManager::suffix_load_till_message_id(Dialog *d, MessageId message_id, Promise<> promise) {
|
||||||
LOG(INFO) << "Load suffix of " << d->dialog_id << " till " << message_id;
|
LOG(INFO) << "Load suffix of " << d->dialog_id << " till " << message_id;
|
||||||
auto condition = [message_id](const Message *m) { return m != nullptr && m->message_id.get() < message_id.get(); };
|
auto condition = [message_id](const Message *m) {
|
||||||
|
return m != nullptr && m->message_id.get() < message_id.get();
|
||||||
|
};
|
||||||
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
|
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1662,7 +1662,9 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise
|
|||||||
[&](telegram_api::encryptedFileEmpty &) {
|
[&](telegram_api::encryptedFileEmpty &) {
|
||||||
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(
|
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(
|
||||||
telegram_api::inputEncryptedFileEmpty());
|
telegram_api::inputEncryptedFileEmpty());
|
||||||
get_file = [] { return telegram_api::make_object<telegram_api::encryptedFileEmpty>(); };
|
get_file = [] {
|
||||||
|
return telegram_api::make_object<telegram_api::encryptedFileEmpty>();
|
||||||
|
};
|
||||||
},
|
},
|
||||||
[&](telegram_api::encryptedFile &file) {
|
[&](telegram_api::encryptedFile &file) {
|
||||||
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(
|
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(
|
||||||
|
@ -1551,7 +1551,9 @@ int32 UpdatesManager::get_short_update_date() const {
|
|||||||
|
|
||||||
tl_object_ptr<td_api::ChatAction> UpdatesManager::convert_send_message_action(
|
tl_object_ptr<td_api::ChatAction> UpdatesManager::convert_send_message_action(
|
||||||
tl_object_ptr<telegram_api::SendMessageAction> action) {
|
tl_object_ptr<telegram_api::SendMessageAction> action) {
|
||||||
auto fix_progress = [](int32 progress) { return progress <= 0 || progress > 100 ? 0 : progress; };
|
auto fix_progress = [](int32 progress) {
|
||||||
|
return progress <= 0 || progress > 100 ? 0 : progress;
|
||||||
|
};
|
||||||
|
|
||||||
switch (action->get_id()) {
|
switch (action->get_id()) {
|
||||||
case telegram_api::sendMessageCancelAction::ID:
|
case telegram_api::sendMessageCancelAction::ID:
|
||||||
|
@ -106,8 +106,7 @@ void scan_fs(CancellationToken &token, CallbackT &&callback) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto files_dir = get_files_dir(file_type);
|
auto files_dir = get_files_dir(file_type);
|
||||||
walk_path(files_dir,
|
walk_path(files_dir, [&](CSlice path, WalkPath::Type type) {
|
||||||
[&](CSlice path, WalkPath::Type type) {
|
|
||||||
if (token) {
|
if (token) {
|
||||||
return WalkPath::Action::Abort;
|
return WalkPath::Action::Abort;
|
||||||
}
|
}
|
||||||
@ -133,8 +132,7 @@ void scan_fs(CancellationToken &token, CallbackT &&callback) {
|
|||||||
info.mtime_nsec = stat.mtime_nsec_;
|
info.mtime_nsec = stat.mtime_nsec_;
|
||||||
callback(info);
|
callback(info);
|
||||||
return WalkPath::Action::Continue;
|
return WalkPath::Action::Continue;
|
||||||
})
|
}).ignore();
|
||||||
.ignore();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -228,7 +228,9 @@ bool PartsManager::is_part_in_streaming_limit(int part_i) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_intersect_with = [&](int64 begin, int64 end) { return max(begin, offset_begin) < min(end, offset_end); };
|
auto is_intersect_with = [&](int64 begin, int64 end) {
|
||||||
|
return max(begin, offset_begin) < min(end, offset_end);
|
||||||
|
};
|
||||||
|
|
||||||
auto streaming_begin = streaming_offset_;
|
auto streaming_begin = streaming_offset_;
|
||||||
auto streaming_end = streaming_offset_ + streaming_limit_;
|
auto streaming_end = streaming_offset_ + streaming_limit_;
|
||||||
|
@ -135,11 +135,9 @@ Result<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_connection(DcId dc_id, b
|
|||||||
<< tag("prefer_ipv6", prefer_ipv6));
|
<< tag("prefer_ipv6", prefer_ipv6));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto last_error_at = std::min_element(options.begin(), options.end(),
|
auto last_error_at = std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
|
||||||
[](const auto &a_option, const auto &b_option) {
|
|
||||||
return a_option.stat->error_at > b_option.stat->error_at;
|
return a_option.stat->error_at > b_option.stat->error_at;
|
||||||
})
|
})->stat->error_at;
|
||||||
->stat->error_at;
|
|
||||||
|
|
||||||
auto result = *std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
|
auto result = *std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
|
||||||
auto &a = *a_option.stat;
|
auto &a = *a_option.stat;
|
||||||
|
@ -229,7 +229,8 @@ void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, c
|
|||||||
|
|
||||||
template <ActorSendType send_type, class EventT>
|
template <ActorSendType send_type, class EventT>
|
||||||
void Scheduler::send_lambda(ActorRef actor_ref, EventT &&lambda) {
|
void Scheduler::send_lambda(ActorRef actor_ref, EventT &&lambda) {
|
||||||
return send_impl<send_type>(actor_ref.get(),
|
return send_impl<send_type>(
|
||||||
|
actor_ref.get(),
|
||||||
[&](ActorInfo *actor_info) {
|
[&](ActorInfo *actor_info) {
|
||||||
event_context_ptr_->link_token = actor_ref.token();
|
event_context_ptr_->link_token = actor_ref.token();
|
||||||
lambda();
|
lambda();
|
||||||
@ -243,7 +244,8 @@ void Scheduler::send_lambda(ActorRef actor_ref, EventT &&lambda) {
|
|||||||
|
|
||||||
template <ActorSendType send_type, class EventT>
|
template <ActorSendType send_type, class EventT>
|
||||||
void Scheduler::send_closure(ActorRef actor_ref, EventT &&closure) {
|
void Scheduler::send_closure(ActorRef actor_ref, EventT &&closure) {
|
||||||
return send_impl<send_type>(actor_ref.get(),
|
return send_impl<send_type>(
|
||||||
|
actor_ref.get(),
|
||||||
[&](ActorInfo *actor_info) {
|
[&](ActorInfo *actor_info) {
|
||||||
event_context_ptr_->link_token = actor_ref.token();
|
event_context_ptr_->link_token = actor_ref.token();
|
||||||
closure.run(static_cast<typename EventT::ActorType *>(actor_info->get_actor_unsafe()));
|
closure.run(static_cast<typename EventT::ActorType *>(actor_info->get_actor_unsafe()));
|
||||||
@ -258,7 +260,8 @@ void Scheduler::send_closure(ActorRef actor_ref, EventT &&closure) {
|
|||||||
template <ActorSendType send_type>
|
template <ActorSendType send_type>
|
||||||
void Scheduler::send(ActorRef actor_ref, Event &&event) {
|
void Scheduler::send(ActorRef actor_ref, Event &&event) {
|
||||||
event.set_link_token(actor_ref.token());
|
event.set_link_token(actor_ref.token());
|
||||||
return send_impl<send_type>(actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); },
|
return send_impl<send_type>(
|
||||||
|
actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); },
|
||||||
[&]() { return std::move(event); });
|
[&]() { return std::move(event); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,8 @@ class BinlogKeyValue : public KeyValueSyncInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binlog_ = std::make_shared<BinlogT>();
|
binlog_ = std::make_shared<BinlogT>();
|
||||||
TRY_STATUS(binlog_->init(name,
|
TRY_STATUS(binlog_->init(
|
||||||
|
name,
|
||||||
[&](const BinlogEvent &binlog_event) {
|
[&](const BinlogEvent &binlog_event) {
|
||||||
Event event;
|
Event event;
|
||||||
event.parse(TlParser(binlog_event.data_));
|
event.parse(TlParser(binlog_event.data_));
|
||||||
|
@ -24,7 +24,9 @@ Result<bool> SqliteKeyValue::init(string path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status SqliteKeyValue::init_with_connection(SqliteDb connection, string table_name) {
|
Status SqliteKeyValue::init_with_connection(SqliteDb connection, string table_name) {
|
||||||
auto init_guard = ScopeExit() + [&]() { close(); };
|
auto init_guard = ScopeExit() + [&]() {
|
||||||
|
close();
|
||||||
|
};
|
||||||
db_ = std::move(connection);
|
db_ = std::move(connection);
|
||||||
table_name_ = std::move(table_name);
|
table_name_ = std::move(table_name);
|
||||||
TRY_STATUS(init(db_, table_name_));
|
TRY_STATUS(init(db_, table_name_));
|
||||||
|
@ -56,7 +56,9 @@ class SqliteStatement {
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
auto guard() {
|
auto guard() {
|
||||||
return ScopeExit{} + [this] { this->reset(); };
|
return ScopeExit{} + [this] {
|
||||||
|
this->reset();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO get row
|
// TODO get row
|
||||||
|
@ -28,7 +28,8 @@ int main(int argc, char *argv[]) {
|
|||||||
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR));
|
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR));
|
||||||
td::Binlog binlog;
|
td::Binlog binlog;
|
||||||
binlog
|
binlog
|
||||||
.init(argv[1],
|
.init(
|
||||||
|
argv[1],
|
||||||
[&](auto &event) {
|
[&](auto &event) {
|
||||||
info[0].compressed_size += event.raw_event_.size();
|
info[0].compressed_size += event.raw_event_.size();
|
||||||
info[event.type_].compressed_size += event.raw_event_.size();
|
info[event.type_].compressed_size += event.raw_event_.size();
|
||||||
|
@ -224,7 +224,9 @@ class SslStreamImpl {
|
|||||||
if (ssl_ctx == nullptr) {
|
if (ssl_ctx == nullptr) {
|
||||||
return create_openssl_error(-7, "Failed to create an SSL context");
|
return create_openssl_error(-7, "Failed to create an SSL context");
|
||||||
}
|
}
|
||||||
auto ssl_ctx_guard = ScopeExit() + [&]() { SSL_CTX_free(ssl_ctx); };
|
auto ssl_ctx_guard = ScopeExit() + [&]() {
|
||||||
|
SSL_CTX_free(ssl_ctx);
|
||||||
|
};
|
||||||
long options = 0;
|
long options = 0;
|
||||||
#ifdef SSL_OP_NO_SSLv2
|
#ifdef SSL_OP_NO_SSLv2
|
||||||
options |= SSL_OP_NO_SSLv2;
|
options |= SSL_OP_NO_SSLv2;
|
||||||
|
@ -22,7 +22,9 @@ namespace td {
|
|||||||
template <int id>
|
template <int id>
|
||||||
static FileFd &get_file_fd() {
|
static FileFd &get_file_fd() {
|
||||||
static FileFd result = FileFd::from_native_fd(NativeFd(id, true));
|
static FileFd result = FileFd::from_native_fd(NativeFd(id, true));
|
||||||
static auto guard = ScopeExit() + [&] { result.move_as_native_fd().release(); };
|
static auto guard = ScopeExit() + [&] {
|
||||||
|
result.move_as_native_fd().release();
|
||||||
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +44,9 @@ static FileFd &get_file_fd() {
|
|||||||
static auto handle = GetStdHandle(id);
|
static auto handle = GetStdHandle(id);
|
||||||
LOG_IF(FATAL, handle == INVALID_HANDLE_VALUE) << "Failed to GetStdHandle " << id;
|
LOG_IF(FATAL, handle == INVALID_HANDLE_VALUE) << "Failed to GetStdHandle " << id;
|
||||||
static FileFd result = FileFd::from_native_fd(NativeFd(handle, true));
|
static FileFd result = FileFd::from_native_fd(NativeFd(handle, true));
|
||||||
static auto guard = ScopeExit() + [&] { result.move_as_native_fd().release(); };
|
static auto guard = ScopeExit() + [&] {
|
||||||
|
result.move_as_native_fd().release();
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
static FileFd result;
|
static FileFd result;
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,9 +31,7 @@ class ThreadPthread {
|
|||||||
ThreadPthread() = default;
|
ThreadPthread() = default;
|
||||||
ThreadPthread(const ThreadPthread &other) = delete;
|
ThreadPthread(const ThreadPthread &other) = delete;
|
||||||
ThreadPthread &operator=(const ThreadPthread &other) = delete;
|
ThreadPthread &operator=(const ThreadPthread &other) = delete;
|
||||||
ThreadPthread(ThreadPthread &&other) noexcept
|
ThreadPthread(ThreadPthread &&other) noexcept : is_inited_(std::move(other.is_inited_)), thread_(other.thread_) {
|
||||||
: is_inited_(std::move(other.is_inited_))
|
|
||||||
, thread_(other.thread_) {
|
|
||||||
}
|
}
|
||||||
ThreadPthread &operator=(ThreadPthread &&other) {
|
ThreadPthread &operator=(ThreadPthread &&other) {
|
||||||
join();
|
join();
|
||||||
|
@ -153,7 +153,8 @@ TEST(Misc, get_last_argument) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Misc, call_n_arguments) {
|
TEST(Misc, call_n_arguments) {
|
||||||
auto f = [](int, int) {};
|
auto f = [](int, int) {
|
||||||
|
};
|
||||||
call_n_arguments<2>(f, 1, 3, 4);
|
call_n_arguments<2>(f, 1, 3, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,8 +758,12 @@ TEST(Misc, uint128) {
|
|||||||
static_cast<int64>(std::numeric_limits<int32>::min()) - 1};
|
static_cast<int64>(std::numeric_limits<int32>::min()) - 1};
|
||||||
|
|
||||||
#if TD_HAVE_INT128
|
#if TD_HAVE_INT128
|
||||||
auto to_intrinsic = [](uint128_emulated num) { return uint128_intrinsic(num.hi(), num.lo()); };
|
auto to_intrinsic = [](uint128_emulated num) {
|
||||||
auto eq = [](uint128_emulated a, uint128_intrinsic b) { return a.hi() == b.hi() && a.lo() == b.lo(); };
|
return uint128_intrinsic(num.hi(), num.lo());
|
||||||
|
};
|
||||||
|
auto eq = [](uint128_emulated a, uint128_intrinsic b) {
|
||||||
|
return a.hi() == b.hi() && a.lo() == b.lo();
|
||||||
|
};
|
||||||
auto ensure_eq = [&](uint128_emulated a, uint128_intrinsic b) {
|
auto ensure_eq = [&](uint128_emulated a, uint128_intrinsic b) {
|
||||||
if (!eq(a, b)) {
|
if (!eq(a, b)) {
|
||||||
LOG(FATAL) << "[" << a.hi() << ";" << a.lo() << "] vs [" << b.hi() << ";" << b.lo() << "]";
|
LOG(FATAL) << "[" << a.hi() << ";" << a.lo() << "] vs [" << b.hi() << ";" << b.lo() << "]";
|
||||||
|
@ -41,33 +41,28 @@ TEST(Port, files) {
|
|||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
const int ITER_COUNT = 1000;
|
const int ITER_COUNT = 1000;
|
||||||
for (int i = 0; i < ITER_COUNT; i++) {
|
for (int i = 0; i < ITER_COUNT; i++) {
|
||||||
walk_path(main_dir,
|
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||||
[&](CSlice name, WalkPath::Type type) {
|
|
||||||
if (type == WalkPath::Type::NotDir) {
|
if (type == WalkPath::Type::NotDir) {
|
||||||
ASSERT_TRUE(name == fd_path || name == fd2_path);
|
ASSERT_TRUE(name == fd_path || name == fd2_path);
|
||||||
}
|
}
|
||||||
cnt++;
|
cnt++;
|
||||||
})
|
}).ensure();
|
||||||
.ensure();
|
|
||||||
}
|
}
|
||||||
ASSERT_EQ((5 * 2 + 2) * ITER_COUNT, cnt);
|
ASSERT_EQ((5 * 2 + 2) * ITER_COUNT, cnt);
|
||||||
bool was_abort = false;
|
bool was_abort = false;
|
||||||
walk_path(main_dir,
|
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||||
[&](CSlice name, WalkPath::Type type) {
|
|
||||||
CHECK(!was_abort);
|
CHECK(!was_abort);
|
||||||
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << TD_DIR_SLASH << "B")) {
|
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << TD_DIR_SLASH << "B")) {
|
||||||
was_abort = true;
|
was_abort = true;
|
||||||
return WalkPath::Action::Abort;
|
return WalkPath::Action::Abort;
|
||||||
}
|
}
|
||||||
return WalkPath::Action::Continue;
|
return WalkPath::Action::Continue;
|
||||||
})
|
}).ensure();
|
||||||
.ensure();
|
|
||||||
CHECK(was_abort);
|
CHECK(was_abort);
|
||||||
|
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
bool is_first_dir = true;
|
bool is_first_dir = true;
|
||||||
walk_path(main_dir,
|
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||||
[&](CSlice name, WalkPath::Type type) {
|
|
||||||
cnt++;
|
cnt++;
|
||||||
if (type == WalkPath::Type::EnterDir) {
|
if (type == WalkPath::Type::EnterDir) {
|
||||||
if (is_first_dir) {
|
if (is_first_dir) {
|
||||||
@ -77,8 +72,7 @@ TEST(Port, files) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return WalkPath::Action::Continue;
|
return WalkPath::Action::Continue;
|
||||||
})
|
}).ensure();
|
||||||
.ensure();
|
|
||||||
ASSERT_EQ(6, cnt);
|
ASSERT_EQ(6, cnt);
|
||||||
|
|
||||||
ASSERT_EQ(0u, fd.get_size().move_as_ok());
|
ASSERT_EQ(0u, fd.get_size().move_as_ok());
|
||||||
|
22
test/db.cpp
22
test/db.cpp
@ -47,11 +47,17 @@ TEST(DB, binlog_encryption_bug) {
|
|||||||
auto empty = DbKey::empty();
|
auto empty = DbKey::empty();
|
||||||
{
|
{
|
||||||
Binlog binlog;
|
Binlog binlog;
|
||||||
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber).ensure();
|
binlog
|
||||||
|
.init(
|
||||||
|
binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber)
|
||||||
|
.ensure();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Binlog binlog;
|
Binlog binlog;
|
||||||
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber).ensure();
|
binlog
|
||||||
|
.init(
|
||||||
|
binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber)
|
||||||
|
.ensure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +98,10 @@ TEST(DB, binlog_encryption) {
|
|||||||
std::vector<string> v;
|
std::vector<string> v;
|
||||||
LOG(INFO) << "RESTART";
|
LOG(INFO) << "RESTART";
|
||||||
Binlog binlog;
|
Binlog binlog;
|
||||||
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, hello).ensure();
|
binlog
|
||||||
|
.init(
|
||||||
|
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, hello)
|
||||||
|
.ensure();
|
||||||
CHECK(v == std::vector<string>({"AAAA", "BBBB", long_data, "CCCC"}));
|
CHECK(v == std::vector<string>({"AAAA", "BBBB", long_data, "CCCC"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +111,8 @@ TEST(DB, binlog_encryption) {
|
|||||||
std::vector<string> v;
|
std::vector<string> v;
|
||||||
LOG(INFO) << "RESTART";
|
LOG(INFO) << "RESTART";
|
||||||
Binlog binlog;
|
Binlog binlog;
|
||||||
auto status = binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber);
|
auto status = binlog.init(
|
||||||
|
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber);
|
||||||
CHECK(status.is_error());
|
CHECK(status.is_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,8 +122,8 @@ TEST(DB, binlog_encryption) {
|
|||||||
std::vector<string> v;
|
std::vector<string> v;
|
||||||
LOG(INFO) << "RESTART";
|
LOG(INFO) << "RESTART";
|
||||||
Binlog binlog;
|
Binlog binlog;
|
||||||
auto status =
|
auto status = binlog.init(
|
||||||
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber, hello);
|
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber, hello);
|
||||||
CHECK(v == std::vector<string>({"AAAA", "BBBB", long_data, "CCCC"}));
|
CHECK(v == std::vector<string>({"AAAA", "BBBB", long_data, "CCCC"}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user