Merge commit 'd5f02b006600724c58edb86d356c494e9d30d1d1'

This commit is contained in:
Andrea Cavalli 2021-03-16 13:07:27 +01:00
commit eb44f72a75
6 changed files with 44 additions and 16 deletions

View File

@ -107,6 +107,15 @@ if (NOT CMAKE_CROSSCOMPILING)
add_subdirectory(tl-parser)
set(TLO_AUTO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/auto/tlo)
set(TLO_FILES ${TLO_AUTO_INCLUDE_DIR}/mtproto_api.tlo ${TLO_AUTO_INCLUDE_DIR}/secret_api.tlo ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo ${TLO_AUTO_INCLUDE_DIR}/telegram_api.tlo)
set(TD_API_TLO_FILE ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo)
# Ninja generator uses relative paths and can't correctly handle these dependencies
# See https://gitlab.kitware.com/cmake/cmake/-/issues/13894
if (CMAKE_GENERATOR STREQUAL "Ninja")
set(TLO_FILES)
set(TD_API_TLO_FILE)
endif()
add_custom_target(tl_generate_tlo
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@ -124,7 +133,7 @@ if (NOT CMAKE_CROSSCOMPILING)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${GENERATE_COMMON_CMD}
COMMENT "Generate common TL source files"
DEPENDS generate_common tl_generate_tlo ${TLO_AUTO_INCLUDE_DIR}/mtproto_api.tlo ${TLO_AUTO_INCLUDE_DIR}/secret_api.tlo ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo ${TLO_AUTO_INCLUDE_DIR}/telegram_api.tlo ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DoxygenTlDocumentationGenerator.php
DEPENDS generate_common tl_generate_tlo ${TLO_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DoxygenTlDocumentationGenerator.php
)
if (TD_ENABLE_JNI)
target_compile_definitions(generate_common PRIVATE TD_ENABLE_JNI=1)
@ -139,7 +148,7 @@ if (NOT CMAKE_CROSSCOMPILING)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND generate_c
COMMENT "Generate C TL source files"
DEPENDS generate_c tl_generate_tlo ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl
DEPENDS generate_c tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl
)
add_executable(td_generate_java_api ${TL_GENERATE_JAVA_SOURCE})
@ -151,7 +160,7 @@ if (NOT CMAKE_CROSSCOMPILING)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND generate_json
COMMENT "Generate JSON TL source files"
DEPENDS generate_json tl_generate_tlo ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl
DEPENDS generate_json tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl
)
if (TD_ENABLE_JNI)
@ -162,9 +171,9 @@ if (NOT CMAKE_CROSSCOMPILING)
if (TD_ENABLE_DOTNET)
if (PHP_EXECUTABLE)
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo && ${PHP_EXECUTABLE} DotnetTlDocumentationGenerator.php scheme/td_api.tl auto/td/telegram/TdDotNetApi.h)
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TD_API_TLO_FILE} && ${PHP_EXECUTABLE} DotnetTlDocumentationGenerator.php scheme/td_api.tl auto/td/telegram/TdDotNetApi.h)
else()
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo)
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TD_API_TLO_FILE})
endif()
add_executable(td_generate_dotnet_api generate_dotnet.cpp tl_writer_dotnet.h)
@ -173,7 +182,7 @@ if (NOT CMAKE_CROSSCOMPILING)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${GENERATE_DOTNET_API_CMD}
COMMENT "Generate .NET API files"
DEPENDS td_generate_dotnet_api tl_generate_tlo ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DotnetTlDocumentationGenerator.php
DEPENDS td_generate_dotnet_api tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DotnetTlDocumentationGenerator.php
)
endif()

View File

@ -13097,7 +13097,7 @@ void ContactsManager::on_update_chat_participant(ChatId chat_id, UserId user_id,
}
if (!chat_id.is_valid() || !user_id.is_valid() || date <= 0 ||
(old_participant == nullptr && new_participant == nullptr)) {
LOG(ERROR) << "Receive invalid updateChatParticipant in " << chat_id << " for " << user_id << " at " << date << ": "
LOG(ERROR) << "Receive invalid updateChatParticipant in " << chat_id << " by " << user_id << " at " << date << ": "
<< to_string(old_participant) << " -> " << to_string(new_participant);
return;
}
@ -13142,7 +13142,7 @@ void ContactsManager::on_update_channel_participant(ChannelId channel_id, UserId
}
if (!channel_id.is_valid() || !user_id.is_valid() || date <= 0 ||
(old_participant == nullptr && new_participant == nullptr)) {
LOG(ERROR) << "Receive invalid updateChannelParticipant in " << channel_id << " for " << user_id << " at " << date
LOG(ERROR) << "Receive invalid updateChannelParticipant in " << channel_id << " by " << user_id << " at " << date
<< ": " << to_string(old_participant) << " -> " << to_string(new_participant);
return;
}

View File

@ -13553,9 +13553,9 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
bool is_pinned = (flags & MESSAGE_FLAG_IS_PINNED) != 0;
LOG_IF(ERROR, is_channel_message != (dialog_type == DialogType::Channel))
<< "is_channel_message is wrong for message received in the " << dialog_id;
<< "is_channel_message is wrong for " << message_id << " received in the " << dialog_id;
LOG_IF(ERROR, is_channel_post && !is_broadcast_channel(dialog_id))
<< "is_channel_post is true for message received in the " << dialog_id;
<< "is_channel_post is true for " << message_id << " received in the " << dialog_id;
UserId my_id = td_->contacts_manager_->get_my_id();
DialogId my_dialog_id = DialogId(my_id);

View File

@ -216,7 +216,7 @@ void UpdatesManager::fill_qts_gap(void *td) {
}
void UpdatesManager::fill_get_difference_gap(void *td) {
fill_gap(td, "rare getDifference calls");
fill_gap(td, nullptr);
}
void UpdatesManager::fill_gap(void *td, const char *source) {
@ -226,7 +226,9 @@ void UpdatesManager::fill_gap(void *td, const char *source) {
}
auto updates_manager = static_cast<Td *>(td)->updates_manager_.get();
LOG(WARNING) << "Filling gap in " << source << " by running getDifference";
if (source != nullptr) {
LOG(WARNING) << "Filling gap in " << source << " by running getDifference";
}
updates_manager->get_difference("fill_gap");
}
@ -359,7 +361,7 @@ Promise<> UpdatesManager::set_pts(int32 pts, const char *source) {
result = add_pts(pts);
if (last_get_difference_pts_ < get_pts() - FORCED_GET_DIFFERENCE_PTS_DIFF) {
last_get_difference_pts_ = get_pts();
schedule_get_difference("set_pts");
schedule_get_difference("rare pts getDifference");
}
} else if (pts < get_pts()) {
LOG(ERROR) << "Receive wrong pts = " << pts << " from " << source << ". Current pts = " << get_pts();
@ -904,8 +906,8 @@ void UpdatesManager::on_failed_get_difference(Status &&error) {
}
void UpdatesManager::schedule_get_difference(const char *source) {
VLOG(get_difference) << "Schedule getDifference from " << source;
if (!retry_timeout_.has_timeout()) {
LOG(WARNING) << "Schedule getDifference in " << retry_time_ << " seconds from " << source;
retry_timeout_.set_callback(std::move(fill_get_difference_gap));
retry_timeout_.set_callback_data(static_cast<void *>(td_));
retry_timeout_.set_timeout_in(retry_time_);
@ -913,6 +915,8 @@ void UpdatesManager::schedule_get_difference(const char *source) {
if (retry_time_ > 60) {
retry_time_ = Random::fast(60, 80);
}
} else {
VLOG(get_difference) << "Schedule getDifference from " << source;
}
}
@ -1653,6 +1657,7 @@ void UpdatesManager::add_pending_qts_update(tl_object_ptr<telegram_api::Update>
CHECK(update != nullptr);
if (qts <= 1) {
LOG(ERROR) << "Receive wrong qts " << qts << " in " << oneline(to_string(update));
schedule_get_difference("wrong qts");
promise.set_value(Unit());
return;
}
@ -1958,7 +1963,7 @@ void UpdatesManager::process_qts_update(tl_object_ptr<telegram_api::Update> &&up
LOG(DEBUG) << "Process " << to_string(update_ptr);
if (last_get_difference_qts_ < qts - FORCED_GET_DIFFERENCE_PTS_DIFF) {
if (last_get_difference_qts_ != 0) {
schedule_get_difference("process_qts_update");
schedule_get_difference("rare qts getDifference");
}
last_get_difference_qts_ = qts;
}

View File

@ -85,6 +85,8 @@ class HttpHeaderCreator {
return CSlice("Not Modified");
case 307:
return CSlice("Temporary Redirect");
case 308:
return CSlice("Permanent Redirect");
case 400:
return CSlice("Bad Request");
case 401:
@ -101,16 +103,28 @@ class HttpHeaderCreator {
return CSlice("Request Timeout");
case 409:
return CSlice("Conflict");
case 410:
return CSlice("Gone");
case 411:
return CSlice("Length Required");
case 412:
return CSlice("Precondition Failed");
case 413:
return CSlice("Request Entity Too Large");
case 414:
return CSlice("Request-URI Too Long");
case 415:
return CSlice("Unsupported Media Type");
case 416:
return CSlice("Range Not Satisfiable");
case 417:
return CSlice("Expectation Failed");
case 418:
return CSlice("I'm a teapot");
case 421:
return CSlice("Misdirected Request");
case 426:
return CSlice("Upgrade Required");
case 429:
return CSlice("Too Many Requests");
case 431:

View File

@ -131,7 +131,7 @@ class RangeSet {
}
return res;
}
int64 get_ready_parts(int64 offset_part, int64 part_size) const {
int64 get_ready_parts(int64 offset_part, int32 part_size) const {
auto offset = offset_part * part_size;
auto it = find(offset);
if (it == ranges_.end()) {