Decrease maximum total_timeout_limit for bots.

GitOrigin-RevId: 8d42ef41c28e8a5a276f4a1b6058c3391419146e
This commit is contained in:
levlam 2020-03-16 04:09:17 +03:00
parent aac59710b4
commit 784836f3b6
3 changed files with 11 additions and 3 deletions

View File

@ -329,7 +329,7 @@ class NetQuery : public ListNode {
NetQueryCounter nq_counter_;
NetQuery(State state, uint64 id, BufferSlice &&query, BufferSlice &&answer, DcId dc_id, Type type, AuthFlag auth_flag,
GzipFlag gzip_flag, int32 tl_constructor)
GzipFlag gzip_flag, int32 tl_constructor, double total_timeout_limit)
: state_(state)
, type_(type)
, auth_flag_(auth_flag)
@ -340,6 +340,7 @@ class NetQuery : public ListNode {
, query_(std::move(query))
, answer_(std::move(answer))
, tl_constructor_(tl_constructor)
, total_timeout_limit(total_timeout_limit)
, nq_counter_(true) {
my_id_ = get_my_id();
start_timestamp_ = Time::now();

View File

@ -6,6 +6,9 @@
//
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/format.h"
@ -51,8 +54,12 @@ NetQueryPtr NetQueryCreator::create(uint64 id, const telegram_api::Function &fun
}
}
double total_timeout_limit = 60;
if (!G()->close_flag() && G()->td().get_actor_unsafe()->auth_manager_->is_bot()) {
total_timeout_limit = 8;
}
auto query = object_pool_.create(NetQuery::State::Query, id, std::move(slice), BufferSlice(), dc_id, type, auth_flag,
gzip_flag, tl_constructor);
gzip_flag, tl_constructor, total_timeout_limit);
query->set_cancellation_token(query.generation());
return query;
}

View File

@ -31,7 +31,7 @@ class NetQueryCreator {
NetQueryPtr create_update(BufferSlice &&buffer) {
return object_pool_.create(NetQuery::State::OK, 0, BufferSlice(), std::move(buffer), DcId::main(),
NetQuery::Type::Common, NetQuery::AuthFlag::On, NetQuery::GzipFlag::Off, 0);
NetQuery::Type::Common, NetQuery::AuthFlag::On, NetQuery::GzipFlag::Off, 0, 0);
}
NetQueryPtr create(const telegram_api::Function &function, DcId dc_id = DcId::main(),