Add debug for INPUT_METHOD_INVALID and BOT_METHOD_INVALID.

GitOrigin-RevId: dfc4e6c81f80504d2299a59f21cd79633fd98daf
This commit is contained in:
levlam 2018-06-08 21:42:04 +03:00
parent 5d1323311a
commit ea8d5dbda7
3 changed files with 17 additions and 9 deletions

View File

@ -38,6 +38,21 @@ int32 NetQuery::tl_magic(const BufferSlice &buffer_slice) {
return as<int32>(slice.begin());
}
void NetQuery::set_error(Status status, string source) {
if (status.code() == Error::Resend || status.code() == Error::Cancelled ||
status.code() == Error::ResendInvokeAfter) {
return set_error_impl(Status::Error(200, PSLICE() << status), std::move(source));
}
if (status.message() == "INPUT_METHOD_INVALID") {
LOG(ERROR) << "Receive INPUT_METHOD_INVALID for query " << format::as_hex_dump<4>(Slice(query_.as_slice()));
}
if (status.message() == "BOT_METHOD_INVALID") {
LOG(ERROR) << "Receive BOT_METHOD_INVALID for query " << format::as_hex(tl_constructor());
}
set_error_impl(std::move(status), std::move(source));
}
void dump_pending_network_queries() {
auto n = NetQueryCounter::get_count();
LOG(WARNING) << tag("pending net queries", n);

View File

@ -133,13 +133,7 @@ class NetQuery : public ListNode {
void on_net_write(size_t size);
void on_net_read(size_t size);
void set_error(Status status, string source = "") {
if (status.code() == Error::Resend || status.code() == Error::Cancelled ||
status.code() == Error::ResendInvokeAfter) {
return set_error_impl(Status::Error(200, PSLICE() << status), std::move(source));
}
set_error_impl(std::move(status), source);
}
void set_error(Status status, string source = "");
void set_error_resend() {
set_error_impl(Status::Error<Error::Resend>());

View File

@ -23,8 +23,7 @@ NetQueryCreator::Ptr NetQueryCreator::create(uint64 id, const Storer &storer, Dc
int32 tl_constructor = NetQuery::tl_magic(slice);
if (gzip_flag == NetQuery::GzipFlag::On) {
// TODO: try to compress files?
BufferSlice compressed;
compressed = gzencode(slice.as_slice());
BufferSlice compressed = gzencode(slice.as_slice());
if (compressed.empty()) {
gzip_flag = NetQuery::GzipFlag::Off;
} else {