From b56e944a6510a7357879aad9ed58c7083b7f28ec Mon Sep 17 00:00:00 2001 From: victor Date: Sat, 14 Nov 2009 15:53:42 +0000 Subject: [PATCH] compromise git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@553 e16421f0-f15b-0410-abcd-98678b794739 --- ext/send_control.cpp | 9 ++++++--- sendrecv.cpp | 10 +++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ext/send_control.cpp b/ext/send_control.cpp index b520210..256bab9 100644 --- a/ext/send_control.cpp +++ b/ext/send_control.cpp @@ -43,13 +43,13 @@ bool KeepAliveController::MaySendData() { void KeepAliveController::OnDataSent(bin64_t b) { if (b==bin64_t::ALL || b==bin64_t::NONE) { - delay_ = delay_ * 2; // backing off if (delay_>TINT_SEC*58) // keep NAT mappings alive delay_ = TINT_SEC*58; if (delay_>=4*TINT_SEC && ch_->last_recv_time_ < NOW-TINT_MIN) Schedule(TINT_NEVER); // no response; enter close timeout else Schedule(NOW+delay_); // all right, just keep it alive + delay_ = delay_ * 2; // backing off } else { Schedule(NOW+ch_->rtt_avg_); // cwnd==1 => next send in 1 rtt Swap(new SlowStartController(this)); @@ -60,6 +60,9 @@ void KeepAliveController::OnDataRecvd(bin64_t b) { if (b!=bin64_t::NONE && b!=bin64_t::ALL) { // channel is alive delay_ = ch_->rtt_avg_; Schedule(NOW); // schedule an ACK; TODO: aggregate + } else { + delay_ = ch_->rtt_avg_; + Schedule(NOW); } } @@ -118,9 +121,9 @@ void CwndController::OnAckRcvd(bin64_t ackd) { else cwnd_ += 1.0/cwnd_; dprintf("%s #%i sendctrl cwnd to %f\n",tintstr(),ch_->id,cwnd_); - tint spacing = ch_->rtt_avg_ / cwnd_; - Schedule(ch_->last_send_time_+spacing); } + tint spacing = ch_->rtt_avg_ / cwnd_; + Schedule(ch_->last_send_time_+spacing); } diff --git a/sendrecv.cpp b/sendrecv.cpp index e93e12c..c570c18 100644 --- a/sendrecv.cpp +++ b/sendrecv.cpp @@ -275,10 +275,6 @@ void Channel::Recv (Datagram& dgram) { } cc_->OnDataRecvd(data); last_recv_time_ = NOW; - if (data!=bin64_t::ALL && next_send_time_>NOW+TINT_MSEC) { - Datagram::Time(); - Send(); - } } @@ -483,9 +479,11 @@ void Channel::Loop (tint howlong) { int rd = Datagram::Wait(socket_count,sockets,towait); if (rd!=INVALID_SOCKET) RecvDatagram(rd); - } else if (sender) { // FIXME FIXME FIXME REWRITE!!! if (sender->next_send_time_==TINT_NEVER) { + } else { // FIXME FIXME FIXME REWRITE!!! if (sender->next_send_time_==TINT_NEVER) { + if (sender) { dprintf("%s #%i closed sendctrl\n",tintstr(),sender->id); delete sender; + } send_queue.pop(); } @@ -495,8 +493,6 @@ void Channel::Loop (tint howlong) { void Channel::Schedule (tint next_time) { - if (next_time==next_send_time_) - return; next_send_time_ = next_time; if (next_time==TINT_NEVER) next_time = NOW + TINT_MIN; // 1min timeout -- 2.20.1