Add more logging for CHECK.

This commit is contained in:
levlam 2021-10-24 13:23:47 +03:00
parent c0fb888c42
commit 2431afc722
3 changed files with 13 additions and 4 deletions

View File

@ -63,7 +63,7 @@ class RawConnection {
virtual ~Callback() = default;
virtual Status on_raw_packet(const PacketInfo &info, BufferSlice packet) = 0;
virtual Status on_quick_ack(uint64 quick_ack_token) {
return Status::Error("Quick acks unsupported fully, but still used");
return Status::Error("Quick acknowledgements are unsupported by the callback");
}
virtual Status before_write() {
return Status::OK();

View File

@ -173,6 +173,7 @@ namespace mtproto {
*/
unique_ptr<RawConnection> SessionConnection::move_as_raw_connection() {
was_moved_ = true;
return std::move(raw_connection_);
}
@ -1007,7 +1008,10 @@ void SessionConnection::send_before(double tm) {
}
Status SessionConnection::do_flush() {
CHECK(raw_connection_);
LOG_CHECK(raw_connection_) << was_moved_ << ' ' << state_ << ' ' << static_cast<int32>(mode_) << ' '
<< connected_flag_ << ' ' << is_main_ << ' ' << need_destroy_auth_key_ << ' '
<< sent_destroy_auth_key_ << ' ' << callback_ << ' ' << (Time::now() - created_at_) << ' '
<< (Time::now() - last_read_at_);
CHECK(state_ != Closed);
if (state_ == Init) {
TRY_STATUS(init());

View File

@ -69,8 +69,13 @@ class SessionConnection final
: public Named
, private RawConnection::Callback {
public:
enum class Mode { Tcp, Http, HttpLongPoll };
enum class Mode : int32 { Tcp, Http, HttpLongPoll };
SessionConnection(Mode mode, unique_ptr<RawConnection> raw_connection, AuthData *auth_data);
SessionConnection(const SessionConnection &) = delete;
SessionConnection &operator=(const SessionConnection &) = delete;
SessionConnection(SessionConnection &&) = delete;
SessionConnection &operator=(SessionConnection &&) = delete;
~SessionConnection() = default;
PollableFdInfo &get_poll_info();
unique_ptr<RawConnection> move_as_raw_connection();
@ -87,7 +92,6 @@ class SessionConnection final
void set_online(bool online_flag, bool is_main);
// Callback
class Callback {
public:
Callback() = default;
@ -132,6 +136,7 @@ class SessionConnection final
bool online_flag_ = false;
bool is_main_ = false;
bool was_moved_ = false;
int rtt() const {
return max(2, static_cast<int>(raw_connection_->extra().rtt * 1.5 + 1));