Fix MTP logging.

This commit is contained in:
John Preston 2019-01-17 11:17:44 +04:00
parent 09d85e25c1
commit 548a0c8517
3 changed files with 8 additions and 9 deletions

View File

@ -1048,7 +1048,6 @@ void mtpTextSerializeType(MTPStringLogger &to, const mtpPrime *&from, const mtpP
types.reserve(20); vtypes.reserve(20); stages.reserve(20); flags.reserve(20);\n\ types.reserve(20); vtypes.reserve(20); stages.reserve(20); flags.reserve(20);\n\
types.push_back(mtpTypeId(cons)); vtypes.push_back(mtpTypeId(vcons)); stages.push_back(0); flags.push_back(0);\n\ types.push_back(mtpTypeId(cons)); vtypes.push_back(mtpTypeId(vcons)); stages.push_back(0); flags.push_back(0);\n\
\n\ \n\
const mtpPrime *start = from;\n\
mtpTypeId type = cons, vtype = vcons;\n\ mtpTypeId type = cons, vtype = vcons;\n\
int32 stage = 0, flag = 0;\n\ int32 stage = 0, flag = 0;\n\
\n\ \n\
@ -1064,13 +1063,13 @@ void mtpTextSerializeType(MTPStringLogger &to, const mtpPrime *&from, const mtpP
throw Exception("unknown type on stage > 0");\n\ throw Exception("unknown type on stage > 0");\n\
}\n\ }\n\
types.back() = type = *from;\n\ types.back() = type = *from;\n\
start = ++from;\n\ ++from;\n\
}\n\ }\n\
\n\ \n\
int32 lev = level + types.size() - 1;\n\ int32 lev = level + types.size() - 1;\n\
auto it = serializers.constFind(type);\n\ auto it = serializers.constFind(type);\n\
if (it != serializers.cend()) {\n\ if (it != serializers.cend()) {\n\
(*it.value())(to, stage, lev, types, vtypes, stages, flags, start, end, flag);\n\ (*it.value())(to, stage, lev, types, vtypes, stages, flags, from, end, flag);\n\
} else {\n\ } else {\n\
mtpTextSerializeCore(to, from, end, type, lev, vtype);\n\ mtpTextSerializeCore(to, from, end, type, lev, vtype);\n\
types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back();\n\ types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back();\n\

View File

@ -1612,7 +1612,7 @@ ConnectionPrivate::HandleResult ConnectionPrivate::handleOneReceived(const mtpPr
case mtpc_gzip_packed: { case mtpc_gzip_packed: {
DEBUG_LOG(("Message Info: gzip container")); DEBUG_LOG(("Message Info: gzip container"));
mtpBuffer response = ungzip(++from, end); mtpBuffer response = ungzip(++from, end);
if (!response.size()) { if (response.empty()) {
return HandleResult::RestartConnection; return HandleResult::RestartConnection;
} }
return handleOneReceived(response.data(), response.data() + response.size(), msgId, serverTime, serverSalt, badTime); return handleOneReceived(response.data(), response.data() + response.size(), msgId, serverTime, serverSalt, badTime);

View File

@ -302,11 +302,11 @@ void mtpTextSerializeCore(MTPStringLogger &to, const mtpPrime *&from, const mtpP
result.resize(0); result.resize(0);
z_stream stream; z_stream stream;
stream.zalloc = 0; stream.zalloc = nullptr;
stream.zfree = 0; stream.zfree = nullptr;
stream.opaque = 0; stream.opaque = nullptr;
stream.avail_in = 0; stream.avail_in = 0;
stream.next_in = 0; stream.next_in = nullptr;
int res = inflateInit2(&stream, 16 + MAX_WBITS); int res = inflateInit2(&stream, 16 + MAX_WBITS);
if (res != Z_OK) { if (res != Z_OK) {
throw Exception(QString("ungzip init, code: %1").arg(res)); throw Exception(QString("ungzip init, code: %1").arg(res));
@ -331,7 +331,7 @@ void mtpTextSerializeCore(MTPStringLogger &to, const mtpPrime *&from, const mtpP
result.resize(result.size() - (stream.avail_out >> 2)); result.resize(result.size() - (stream.avail_out >> 2));
inflateEnd(&stream); inflateEnd(&stream);
if (!result.size()) { if (result.empty()) {
throw Exception("ungzip void data"); throw Exception("ungzip void data");
} }
const mtpPrime *newFrom = result.constData(), *newEnd = result.constData() + result.size(); const mtpPrime *newFrom = result.constData(), *newEnd = result.constData() + result.size();