X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/4782a5c5afee47721cc617daa40dd29828342c2b..3d939725e66414faa7684bbcd5f4ffe95ee2108d:/lcore.pas diff --git a/lcore.pas b/lcore.pas index 900bc96..f6b0342 100755 --- a/lcore.pas +++ b/lcore.pas @@ -35,7 +35,10 @@ interface const - receivebufsize=1460; + receivebufsize=1460*8; + + var + absoloutemaxs:integer=0; type {$ifdef ver1_0} @@ -96,6 +99,7 @@ interface onfdwrite : procedure (Sender: TObject; Error: word) of object; //added for bewarehttpd lasterror:integer; destroying:boolean; + recvbufsize:integer; function receivestr:string; virtual; procedure close; procedure abort; @@ -326,6 +330,7 @@ end; constructor tlasio.create; begin inherited create(AOwner); + if not assigned(eventcore) then raise exception.create('no event core'); sendq := tfifo.create; recvq := tfifo.create; state := wsclosed; @@ -351,8 +356,8 @@ begin if nextasin <> nil then begin nextasin.prevasin := prevasin; end; - recvq.destroy; - sendq.destroy; + recvq.free; + sendq.free; inherited destroy; end; @@ -392,7 +397,7 @@ end; procedure tlasio.internalclose(error:word); begin - if state<>wsclosed then begin + if (state<>wsclosed) and (state<>wsinvalidstate) then begin if (fdhandlein < 0) or (fdhandleout < 0) then raise exception.create('internalclose called with invalid fd handles'); eventcore.rmasterclr(fdhandlein);//fd_clr(fdhandlein,fdsrmaster); eventcore.wmasterclr(fdhandleout);//fd_clr(fdhandleout,fdswmaster); @@ -419,7 +424,7 @@ begin if assigned(onsessionclosed) then if not destroying then onsessionclosed(self,error); end; - sendq.del(maxlongint); + if assigned(sendq) then sendq.del(maxlongint); end; @@ -548,6 +553,7 @@ procedure tlasio.handlefdtrigger(readtrigger,writetrigger:boolean); var sendflushresult : integer; tempbuf:array[0..receivebufsize-1] of byte; + a:integer; begin if (state=wsconnected) and writetrigger then begin //writeln('write trigger'); @@ -574,7 +580,9 @@ begin writtenthiscycle := false; if (state =wsconnected) and readtrigger then begin if recvq.size=0 then begin - numread := myfdread(fdhandlein,tempbuf,sizeof(tempbuf)); + a := recvbufsize; + if (a <= 0) or (a > sizeof(tempbuf)) then a := sizeof(tempbuf); + numread := myfdread(fdhandlein,tempbuf,a); if (numread=0) and (not mustrefreshfds) then begin {if i remember correctly numread=0 is caused by eof if this isn't dealt with then you get a cpu eating infinite loop