From 2189905860ab80725663e2e5a789f5810b94437a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Sat, 7 Nov 2015 21:27:33 +0100 Subject: [PATCH] fuck --- Download.pas | 20 +++++++++++--------- Store1.pas | 2 +- Upload.pas | 6 ++++-- UploadTC.pas | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Download.pas b/Download.pas index ed8b45a..9f50e60 100644 --- a/Download.pas +++ b/Download.pas @@ -195,9 +195,7 @@ procedure tJob.ReplyGET(msg:tSMsg; data:boolean); var rfinal:byte; begin {reply from GET request} - write('Download: ReplyGET: '); if not data then begin - writeln('ack'); end else begin ch.Ack; op:=msg.stream.ReadByte; @@ -207,6 +205,7 @@ procedure tJob.ReplyGET(msg:tSMsg; data:boolean); error:=r.ReadByte; error2:=r.ReadByte; except end; + write('Download: ReplyGET: '); writeln('FAIL ',error,'-',error2); end else if op=upINFO then begin @@ -214,13 +213,13 @@ procedure tJob.ReplyGET(msg:tSMsg; data:boolean); rsize :=r.ReadWord(4); rfinal :=r.readbyte; rseg :=r.readword(4); - writeln('INFO size=',rsize,' final=',rfinal,' seg=',rseg); + //writeln('INFO size=',rsize,' final=',rfinal,' seg=',rseg); if (rsize<>so.length) then writeln('Download: length mismatch ',so.length,'->',rsize); total:=rsize; so.SetFLength(total); - taggr(aggr^).StartT:=mNow; {FIXME} //UnShedule(@HardTimeout); end else if op=opcode.upDONE then begin + write('Download: ReplyGET: '); writeln('DONE'); assert(so.Length>0); so.GetMiss(rofs,rlen); @@ -229,6 +228,7 @@ procedure tJob.ReplyGET(msg:tSMsg; data:boolean); writeln('Download: completed'); end else StartTransfer(false); end else begin + write('Download: ReplyGET: '); if op=upClose then writeln('CLOSE') else writeln('unknown'); state:=stError; error:=254; @@ -258,11 +258,13 @@ procedure tJob.MsgDATA(base,length:LongWord; data:pointer); begin so.WriteSeg(base,length,data); done:=done+length; - (* if rlen=length then begin - ... - else if rlen>length then dec(rlen,length); - *) + so.GetMiss(rofs,rlen); + if rlen=0 then begin + state:=stDone; + writeln('Download: completed'); + end else StartTransfer(false); + end else if rlen>length then dec(rlen,length); end; procedure tAggr.Init(const src:tNetAddr); @@ -328,7 +330,7 @@ procedure tAggr.MsgDATA(sz:Word; mark:byte); delta:=(mNow-StartT){*MSecsPerDay}; if delta<400 then exit; rate:=(ByteCnt/delta)*1000; - writeln('Download: rate ',(rate/1024):7:1, 'kB/s'); + //writeln('Download: rate ',(rate/1024):7:1, 'kB/s'); rateb:=round((rate)/64); StartT:=mNow; ByteCnt:=1; diff --git a/Store1.pas b/Store1.pas index 8cdb570..79c28d3 100644 --- a/Store1.pas +++ b/Store1.pas @@ -161,7 +161,7 @@ end; procedure tStoreObjectInfo.SetFLength(len:LongWord); begin assert(not final); - writeln('Store1: SetFLength ',len); + //writeln('Store1: SetFLength ',len); length:=len; {todo: errors!!!} FileSeek(dh,len,fsFromBeginning); diff --git a/Upload.pas b/Upload.pas index c981a0a..39f4f3e 100644 --- a/Upload.pas +++ b/Upload.pas @@ -196,7 +196,8 @@ procedure ChatHandler(var nchat:tChat; msg:tSMsg); msg.stream.skip({the initcode}1); if msg.stream.RdBufLen<2 then begin SendError(nchat,upErrMalformed,0); exit end; chan:=msg.stream.ReadByte; - if chan=>high(tAggr.chan) then begin Senderror(nchat,upErrHiChan,chan); exit end; + writeln(chan); + if chan>high(tAggr.chan) then begin Senderror(nchat,upErrHiChan,chan); exit end; ag:=FindAggr(msg.source^); if not assigned(ag) then begin New(ag); @@ -238,7 +239,8 @@ procedure tAggr.Start(ac:byte); assert(not assigned(thr.chans[ac])); thr.chans[ac]:=@chan[ac]^.us; chan[ac]^.us.wcur:=chan[ac]^.us.weight; - if (thr.stop)or(thr.wait) then Shedule(700,@Periodic); + UnShedule(@Periodic); + Shedule(700,@Periodic); thr.Start; LeaveCriticalSection(thr.crit); end; diff --git a/UploadTC.pas b/UploadTC.pas index a18c17d..fa3b986 100644 --- a/UploadTC.pas +++ b/UploadTC.pas @@ -17,7 +17,7 @@ procedure tAggr.CalcRates(rxRate:Single); if txRate=0 then txRate:=1; RateFill:=rxRate/txRate; write('speed: ',(rxRate/1024):8:2,'kB/s (',(RateFill*100):3:0,'% of ',txRate/1024:8:2,'), '); - if RateFill<0.95 then begin + if RateFill<0.90 then begin write('limit'); if RateFill<0.5 then thr.size1:=round(thr.size1*0.75); thr.Rate:=rxRate; -- 2.11.4.GIT