Minor improvements.

GitOrigin-RevId: 25ac84d8020557804fc89845e9764c3d50b098d3
This commit is contained in:
levlam 2018-11-20 20:52:42 +03:00
parent c6dd53a76e
commit 16707b0602
2 changed files with 7 additions and 9 deletions

View File

@ -979,16 +979,14 @@ Status SessionConnection::do_flush() {
TRY_STATUS(raw_connection_->flush(auth_data_->get_auth_key(), *this));
// check last pong
if (last_pong_at_ != 0 && last_pong_at_ + ping_disconnect_delay() < Time::now_cached()) {
if (last_pong_at_ + ping_disconnect_delay() < Time::now_cached()) {
raw_connection_->stats_callback()->on_error();
return Status::Error(PSLICE() << "No pong :( " << tag("rtt", rtt()) << tag("delay", ping_disconnect_delay()));
return Status::Error(PSLICE() << "Ping timeout of " << ping_disconnect_delay() << " seconds expired");
}
// check last pong
if (last_read_at_ != 0 && last_read_at_ + read_disconnect_delay() < Time::now_cached()) {
if (last_read_at_ + read_disconnect_delay() < Time::now_cached()) {
raw_connection_->stats_callback()->on_error();
return Status::Error("No read :(");
return Status::Error(PSLICE() << "Read timeout of " << read_disconnect_delay() << " seconds expired");
}
return Status::OK();

View File

@ -130,7 +130,7 @@ class SessionConnection
return max(2, static_cast<int>(raw_connection_->rtt_ * 1.5 + 1));
}
int32 read_disconnect_delay() {
int32 read_disconnect_delay() const {
return online_flag_ ? rtt() * 7 / 2 : 135;
}
@ -149,8 +149,8 @@ class SessionConnection
int http_max_wait() const {
return 25 * 1000; // 25s. Longer could be closed by proxy
}
static constexpr int HTTP_MAX_AFTER = 10; // 0.001s
static constexpr int HTTP_MAX_DELAY = 30; // 0.003s
static constexpr int HTTP_MAX_AFTER = 10; // 0.01s
static constexpr int HTTP_MAX_DELAY = 30; // 0.03s
static constexpr int TEMP_KEY_TIMEOUT = 60 * 60 * 24; // one day
vector<Query> to_send_;