this bug almost killed me
authorVictor Grishchenko <victor.grishchenko@gmail.com>
Wed, 16 Dec 2009 15:45:40 +0000 (16:45 +0100)
committerVictor Grishchenko <victor.grishchenko@gmail.com>
Wed, 16 Dec 2009 15:45:40 +0000 (16:45 +0100)
send_control.cpp
sendrecv.cpp

index 4938c2d..d6d553b 100644 (file)
@@ -128,10 +128,12 @@ tint    Channel::SlowStartNextSendTime () {
 tint    Channel::AimdNextSendTime () {
     if (ack_not_rcvd_recent_)
         BackOffOnLosses();
-    if (cwnd_>1)
-        cwnd_ += ack_rcvd_recent_/cwnd_;
-    else
-        cwnd_ *= 2;
+    if (ack_rcvd_recent_) {
+        if (cwnd_>1)
+            cwnd_ += ack_rcvd_recent_/cwnd_;
+        else
+            cwnd_ *= 2;
+    }
     ack_rcvd_recent_=0;
     return CwndRateNextSendTime();
 }
index 84577c0..6e31e4a 100644 (file)
@@ -123,11 +123,13 @@ void    Channel::Send () {
             tintstr(),id,dgram.size(),peer().str(),peer_channel_id_);
     if (dgram.size()==4) {// only the channel id; bare keep-alive
         data = bin64_t::ALL;
+        //dprintf("%s #%u considering keepalive %i %f %s\n",
+        //        tintstr(),id,(int)data_out_.size(),cwnd_,SEND_CONTROL_MODES[send_control_]);
         if (data_out_.size()<cwnd_ && send_control_!=KEEP_ALIVE_CONTROL) {
             if ( cwnd_ < 1 )
                 SwitchSendControl(KEEP_ALIVE_CONTROL);
             else
-                cwnd_ /= 2;
+                cwnd_ = cwnd_/2.0;
         }
         //if (data_out_.empty() && send_control_!=KEEP_ALIVE_CONTROL)
         //     SwitchSendControl(KEEP_ALIVE_CONTROL);// we did our best