@@ -36,7 +36,7 @@ interface
36
36
HSlib, traylib, monoLib, progFrmLib, classesLib;
37
37
38
38
const
39
- VERSION = ' 2.4.0 beta10 ' ;
39
+ VERSION = ' 2.4.0 RC1 ' ;
40
40
VERSION_BUILD = ' 312' ;
41
41
VERSION_STABLE = { $IFDEF STABLE } TRUE { $ELSE} FALSE { $ENDIF} ;
42
42
CURRENT_VFS_FORMAT :integer = 1 ;
@@ -3458,7 +3458,6 @@ function shouldRecur(data:TconnData):boolean;
3458
3458
3459
3459
function Tmainfrm.getFolderPage (folder:Tfile; cd:TconnData; otpl:Tobject):string;
3460
3460
// we pass the Tpl parameter as Tobject because symbol Ttpl is not defined yet
3461
-
3462
3461
var
3463
3462
baseurl, list, fileTpl, folderTpl, linkTpl: string;
3464
3463
table: TStringDynArray;
@@ -3606,13 +3605,52 @@ function Tmainfrm.getFolderPage(folder:Tfile; cd:TconnData; otpl:Tobject):string
3606
3605
fast.append(s);
3607
3606
end ; // handleItem
3608
3607
3608
+ const ip2availability: Tdictionary<string,Tdatetime> = NIL ;
3609
+ const folderConcurrents: integer = 0 ;
3610
+
3611
+ procedure updateAvailability ();
3612
+ var
3613
+ pair: Tpair<string,Tdatetime>;
3614
+ t: Tdatetime;
3615
+ begin
3616
+ dec(folderConcurrents);
3617
+ t:=now();
3618
+ ip2availability[cd.address]:=t+1 /SECONDS;
3619
+ // purge leftovers
3620
+ for pair in ip2availability do
3621
+ if pair.Value < t then
3622
+ ip2availability.Remove(pair.Key);
3623
+ end ;
3624
+
3625
+ function available ():boolean;
3626
+ begin
3627
+ if ip2availability = NIL then
3628
+ ip2availability:=Tdictionary<string,Tdatetime>.create();
3629
+ try
3630
+ if ip2availability[cd.address] > now() then // this specific address has to wait?
3631
+ exit(FALSE);
3632
+ except
3633
+ end ;
3634
+ if folderConcurrents >= 3 then // max number of concurrent folder loading, others are postponed
3635
+ exit(FALSE);
3636
+ inc(folderConcurrents);
3637
+ ip2availability.AddOrSetValue(cd.address, now()+1 );
3638
+ result:=TRUE;
3639
+ end ; // available
3640
+
3609
3641
var
3610
3642
i, n: integer;
3611
3643
f: Tfile;
3612
3644
begin
3613
3645
result:=' ' ;
3614
3646
if (folder = NIL ) or not folder.isFolder() then exit;
3615
3647
3648
+ if not available() then
3649
+ begin
3650
+ cd.conn.reply.mode:=HRM_OVERLOAD;
3651
+ cd.conn.addHeader(' Refresh: ' +intToStr(1 +random(2 ))); // random for less collisions
3652
+ exit(' Please wait, server busy' );
3653
+ end ;
3616
3654
if macrosLogChk.checked and not appendmacroslog1.checked then
3617
3655
resetLog();
3618
3656
diffTpl:=Ttpl.create();
@@ -3735,6 +3773,7 @@ function Tmainfrm.getFolderPage(folder:Tfile; cd:TconnData; otpl:Tobject):string
3735
3773
result:=replaceText(result, ' %build-time%' ,
3736
3774
floatToStrF((now()-buildTime)*SECONDS, ffFixed, 7 ,3 ) );
3737
3775
finally
3776
+ updateAvailability();
3738
3777
folder.unlock();
3739
3778
diffTpl.free;
3740
3779
end ;
@@ -5184,7 +5223,8 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
5184
5223
5185
5224
if conn.reply.contentType = ' ' then
5186
5225
conn.reply.contentType:=ansistring(if_(trim(getTill(' <' , s))=' ' , ' text/html' , ' text/plain' ))+' ; charset=utf-8' ;
5187
- conn.reply.mode:=HRM_REPLY;
5226
+ if conn.reply.mode = HRM_IGNORE then
5227
+ conn.reply.mode:=HRM_REPLY;
5188
5228
conn.reply.bodyMode:=RBM_STRING;
5189
5229
conn.reply.body:=UTF8encode(s);
5190
5230
compressReply(data);
@@ -5427,6 +5467,12 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
5427
5467
if conn.reply.mode = HRM_REDIRECT then
5428
5468
exit;
5429
5469
5470
+ lastActivityTime:=now();
5471
+ if conn.request.method = HM_HEAD then
5472
+ conn.reply.mode:=HRM_REPLY_HEADER
5473
+ else
5474
+ conn.reply.mode:=HRM_REPLY;
5475
+
5430
5476
if ansiStartsStr(' /~img' , url) then
5431
5477
begin
5432
5478
if not sendPic(data) then
@@ -5579,6 +5625,8 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
5579
5625
if ansiStartsStr(' ~files.lst' , urlCmd)
5580
5626
or f.isFolder() and (data.urlvars.values[' tpl' ] = ' list' ) then
5581
5627
begin
5628
+ if conn.reply.mode=HRM_REPLY_HEADER then
5629
+ exit;
5582
5630
// load from external file
5583
5631
s:=cfgPath+FILELIST_TPL_FILE;
5584
5632
if newMtime(s, lastFilelistTpl) then
@@ -5605,19 +5653,12 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
5605
5653
exit;
5606
5654
end ;
5607
5655
5608
- case conn.request.method of
5609
- HM_GET, HM_POST:
5610
- begin
5611
- conn.reply.mode:=HRM_REPLY;
5612
- lastActivityTime:=now();
5613
- end ;
5614
- HM_HEAD: conn.reply.mode:=HRM_REPLY_HEADER;
5615
- end ;
5616
-
5617
5656
data.lastFile:=f; // auto-freeing
5618
5657
5619
5658
if f.isFolder() then
5620
5659
begin
5660
+ if conn.reply.mode=HRM_REPLY_HEADER then
5661
+ exit;
5621
5662
deletion();
5622
5663
if sessionRedirect() then
5623
5664
exit;
0 commit comments