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));
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);
}
}
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);
}
}
cc_->OnDataRecvd(data);
last_recv_time_ = NOW;
- if (data!=bin64_t::ALL && next_send_time_>NOW+TINT_MSEC) {
- Datagram::Time();
- Send();
- }
}
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();
}
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