fixing data_out_
authorvictor <victor@e16421f0-f15b-0410-abcd-98678b794739>
Tue, 10 Nov 2009 09:05:37 +0000 (09:05 +0000)
committervictor <victor@e16421f0-f15b-0410-abcd-98678b794739>
Tue, 10 Nov 2009 09:05:37 +0000 (09:05 +0000)
git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@521 e16421f0-f15b-0410-abcd-98678b794739

ext/send_control.cpp
ext/send_control.h
hashtree.h
sendrecv.cpp

index 829bc96..7fa41e3 100644 (file)
@@ -98,7 +98,10 @@ void    CwndController::OnDataRecvd(bin64_t b) {
     
 void    CwndController::OnAckRcvd(bin64_t ackd) {
     if (ackd==bin64_t::NONE) {
-        cwnd_ /= 2;
+        if (NOW>last_change_+ch_->rtt_avg_) {
+            cwnd_ /= 2;
+            last_change_ = NOW;
+        }
     } else {
         if (cwnd_<1)
             cwnd_ *= 2;
index 1f31aaa..3489a22 100644 (file)
@@ -80,10 +80,11 @@ struct KeepAliveController : public SendController {
 
 struct CwndController : public SendController {
     
-    double   cwnd_;
+    double  cwnd_;
+    tint    last_change_;
     
     CwndController(SendController* orig, int cwnd=1) :
-    SendController(orig), cwnd_(cwnd) {    }
+    SendController(orig), cwnd_(cwnd), last_change_(0) {    }
     
     bool    MaySendData() ;
     tint    NextSendTime () ;
index b24c75c..0f97618 100644 (file)
@@ -93,7 +93,7 @@ public:
     uint64_t        complete_kilo () const { return completek_; }
     uint64_t        seq_complete () ;
     bool            is_complete () 
-        { return size_ && seq_complete()==size_; }
+        { return size_ && complete_==size_; }
     bins&           ack_out () { return ack_out_; }
        
        ~HashTree ();
index 7a8a5d4..01d799f 100644 (file)
@@ -104,6 +104,8 @@ void    Channel::ClearStaleDataOut() {
         data_out_.pop_front();
     if (data_out_.size()!=oldsize)
         cc_->OnAckRcvd(bin64_t::NONE);
+    while (data_out_.size() && ack_in_.get(data_out_.front().bin)==bins::FILLED)
+        data_out_.pop_front();
 }
 
 
@@ -143,12 +145,15 @@ void      Channel::AddHint (Datagram& dgram) {
         tintbin f = hint_out_.front();
         if (f.time<NOW-rtt_avg_*8) {
             hint_out_.pop_front();
+            transfer().picker().Expired(f.bin);
         } else {
             int status = file().ack_out().get(f.bin);
             if (status==bins::EMPTY) {
+                transfer().picker().Received(f.bin);
                 break;
             } else if (status==bins::FILLED) {
                 hint_out_.pop_front();
+                transfer().picker().Expired(f.bin);
             } else { // mixed
                 hint_out_.front().bin = f.bin.right();
                 f.bin = f.bin.left();