summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a83971b)
function tfifo.get;\r
var\r
p:tlinklist;\r
function tfifo.get;\r
var\r
p:tlinklist;\r
begin\r
if len > size then len := size;\r
if len <= 0 then begin\r
begin\r
if len > size then len := size;\r
if len <= 0 then begin\r
----------------------------------------------------------------------------- }\r
unit binipstuff;\r
\r
----------------------------------------------------------------------------- }\r
unit binipstuff;\r
\r
+{$ifdef fpc}\r
+{$mode delphi}\r
+{$endif}\r
+\r
interface\r
\r
{$include lcoreconfig.inc}\r
interface\r
\r
{$include lcoreconfig.inc}\r
-{$ifdef fpc}\r
- {$mode delphi}\r
-{$endif}\r
{$ifdef cpu386}{$define i386}{$endif}\r
{$ifdef i386}{$define ENDIAN_LITTLE}{$endif}\r
\r
{$ifdef cpu386}{$define i386}{$endif}\r
{$ifdef i386}{$define ENDIAN_LITTLE}{$endif}\r
\r
f,g:float;\r
o:tosversioninfo;\r
isnt:boolean;\r
f,g:float;\r
o:tosversioninfo;\r
isnt:boolean;\r
begin\r
if (performancecountfreq = 0) then qpctimefloat;\r
ticks_freq_known := false;\r
begin\r
if (performancecountfreq = 0) then qpctimefloat;\r
ticks_freq_known := false;\r
o.dwOSVersionInfoSize := sizeof(o);\r
getversionex(o);\r
isnt := o.dwPlatformId = VER_PLATFORM_WIN32_NT;\r
o.dwOSVersionInfoSize := sizeof(o);\r
getversionex(o);\r
isnt := o.dwPlatformId = VER_PLATFORM_WIN32_NT;\r
- is9x := o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;\r
+{ is9x := o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;}\r
\r
ticks_freq2 := f;\r
mmtime_synchedqpc := false;\r
\r
ticks_freq2 := f;\r
mmtime_synchedqpc := false;\r
maxretries=5;\r
margin=0.002;\r
var\r
maxretries=5;\r
margin=0.002;\r
var\r
- jump:float;\r
- mm,f,qpc,newdrift,f1,f2:float;\r
+{ jump:float;}\r
+ mm,f,qpc,newdrift:float;\r
- a,b,c:integer;\r
- retrycount:integer;\r
+ a,b:integer;\r
+{ retrycount:integer;}\r
begin\r
if not ticks_freq_known then measure_ticks_freq;\r
begin\r
if not ticks_freq_known then measure_ticks_freq;\r
- retrycount := maxretries;\r
+{ retrycount := maxretries;}\r
\r
qpc := qpctimefloat;\r
mm := mmtimefloat;\r
\r
qpc := qpctimefloat;\r
mm := mmtimefloat;\r
mmtime_prev_lastsyncqpc := mmtime_lastsyncqpc;\r
\r
mm := mmtimefloat;\r
mmtime_prev_lastsyncqpc := mmtime_lastsyncqpc;\r
\r
mm := mmtimefloat;\r
settc;\r
result := qpctimefloat;\r
f := mmtimefloat;\r
settc;\r
result := qpctimefloat;\r
f := mmtimefloat;\r
{ mmtime_drift := mmtime_drift + mmtime_driftavg[a];}\r
end;\r
{ mmtime_drift := mmtime_drift / b;}\r
{ mmtime_drift := mmtime_drift + mmtime_driftavg[a];}\r
end;\r
{ mmtime_drift := mmtime_drift / b;}\r
if (b = 1) then a := 5 else if (b = 2) then a := 15 else if (b = 3) then a := 30 else if (b = 4) then a := 60 else if (b = 5) then a := 120 else if (b >= 5) then a := 120;\r
mmtime_nextdriftcorrection := qpc + a;\r
if (b >= 2) then warmup_finished := true;\r
if (b = 1) then a := 5 else if (b = 2) then a := 15 else if (b = 3) then a := 30 else if (b = 4) then a := 60 else if (b = 5) then a := 120 else if (b >= 5) then a := 120;\r
mmtime_nextdriftcorrection := qpc + a;\r
if (b >= 2) then warmup_finished := true;\r
qpc := qpctimefloat;\r
\r
result := (qpc - mmtime_lastsyncqpc) * mmtime_drift + mmtime_lastsyncmm;\r
qpc := qpctimefloat;\r
\r
result := (qpc - mmtime_lastsyncqpc) * mmtime_drift + mmtime_lastsyncmm;\r
- f := (qpc - mmtime_prev_lastsyncqpc) * mmtime_prev_drift + mmtime_prev_lastsyncmm;\r
+ {f := (qpc - mmtime_prev_lastsyncqpc) * mmtime_prev_drift + mmtime_prev_lastsyncmm;\r
- {writeln('jump ',formatfloat('0.000000',jump),' drift ',formatfloat('0.00000000',mmtime_drift),' duration ',formatfloat('0.000',(mmtime_lastsyncqpc-mmtime_prev_lastsyncqpc)),' ',formatfloat('0.00000000',jump/(mmtime_lastsyncqpc-mmtime_prev_lastsyncqpc)));}\r
+ writeln('jump ',formatfloat('0.000000',jump),' drift ',formatfloat('0.00000000',mmtime_drift),' duration ',formatfloat('0.000',(mmtime_lastsyncqpc-mmtime_prev_lastsyncqpc)),' ',formatfloat('0.00000000',jump/(mmtime_lastsyncqpc-mmtime_prev_lastsyncqpc)));}\r
\r
{$i unixstuff.inc}\r
\r
\r
{$i unixstuff.inc}\r
\r
+\r
+{$ifdef syncdnscore}\r
var\r
numsockused:integer;\r
fd:array[0..numsock-1] of integer;\r
state:array[0..numsock-1] of tdnsstate;\r
toaddr:array[0..numsock-1] of tbinip;\r
\r
var\r
numsockused:integer;\r
fd:array[0..numsock-1] of integer;\r
state:array[0..numsock-1] of tdnsstate;\r
toaddr:array[0..numsock-1] of tbinip;\r
\r
-{$ifdef syncdnscore}\r
-\r
{$ifdef win32}\r
const\r
winsocket = 'wsock32.dll';\r
{$ifdef win32}\r
const\r
winsocket = 'wsock32.dll';\r
\r
function sendquery(socknum:integer;const packet:tdnspacket;len:integer):boolean;\r
var\r
\r
function sendquery(socknum:integer;const packet:tdnspacket;len:integer):boolean;\r
var\r
addr : ansistring;\r
port : ansistring;\r
inaddr : TInetSockAddrV;\r
addr : ansistring;\r
port : ansistring;\r
inaddr : TInetSockAddrV;\r
currenttime : integer;\r
\r
lag : ttimeval;\r
currenttime : integer;\r
\r
lag : ttimeval;\r
- currenttimeout : ttimeval;\r
selecttimeout : ttimeval;\r
socknum:integer;\r
needprocessing:array[0..numsock-1] of boolean;\r
selecttimeout : ttimeval;\r
socknum:integer;\r
needprocessing:array[0..numsock-1] of boolean;\r
function forwardlookuplist(name:ansistring;timeout:integer):tbiniplist;\r
var\r
dummy : integer;\r
function forwardlookuplist(name:ansistring;timeout:integer):tbiniplist;\r
var\r
dummy : integer;\r
biniptemp:tbinip;\r
l:tbiniplist;\r
begin\r
biniptemp:tbinip;\r
l:tbiniplist;\r
begin\r
tdnswinasync=class(tthread)\r
private\r
freverse : boolean;\r
tdnswinasync=class(tthread)\r
private\r
freverse : boolean;\r
freewhendone : boolean;\r
hadevent : boolean;\r
protected\r
freewhendone : boolean;\r
hadevent : boolean;\r
protected\r
hostent : phostent;\r
addrlist:^pointer;\r
begin\r
hostent : phostent;\r
addrlist:^pointer;\r
begin\r
if hints.ai_family <> af_inet6 then begin\r
result := 0;\r
\r
if hints.ai_family <> af_inet6 then begin\r
result := 0;\r
\r
if assigned (dwas.onrequestdone) then dwas.onrequestdone(dwas,awparam);\r
dwas.hadevent := true;\r
if dwas.freewhendone then dwas.free;\r
if assigned (dwas.onrequestdone) then dwas.onrequestdone(dwas,awparam);\r
dwas.hadevent := true;\r
if dwas.freewhendone then dwas.free;\r
+ result := 0; {added returning 0 when handling --beware}\r
end else begin\r
//not passing unknown messages on to defwindowproc will cause window\r
//creation to fail! --plugwash\r
end else begin\r
//not passing unknown messages on to defwindowproc will cause window\r
//creation to fail! --plugwash\r
\r
{!!! added sleep call -beware}\r
procedure sleep(i:integer);\r
\r
{!!! added sleep call -beware}\r
procedure sleep(i:integer);\r
+{$ifdef win32}\r
+begin\r
+ windows.sleep(i);\r
+{$else}\r
var\r
tv:ttimeval;\r
begin\r
var\r
tv:ttimeval;\r
begin\r
- {$ifdef win32}\r
- windows.sleep(i);\r
- {$else}\r
- tv.tv_sec := i div 1000;\r
- tv.tv_usec := (i mod 1000) * 1000;\r
- select(0,nil,nil,nil,@tv);\r
- {$endif}\r
+ tv.tv_sec := i div 1000;\r
+ tv.tv_usec := (i mod 1000) * 1000;\r
+ select(0,nil,nil,nil,@tv);\r
+{$endif}\r
destructor tlcomponent.destroy;\r
begin\r
disconnecttasks(self);\r
destructor tlcomponent.destroy;\r
begin\r
disconnecttasks(self);\r
\r
procedure processtimers;inline;\r
var\r
\r
procedure processtimers;inline;\r
var\r
- tv ,tvnow : ttimeval ;\r
currenttimer : tltimer ;\r
temptimer : tltimer ;\r
\r
currenttimer : tltimer ;\r
temptimer : tltimer ;\r
\r
procedure processasios(var fdsr,fdsw:fdset);//inline;\r
var\r
currentsocket : tlasio ;\r
procedure processasios(var fdsr,fdsw:fdset);//inline;\r
var\r
currentsocket : tlasio ;\r
- tempsocket : tlasio ;\r
socketcount : integer ; // for debugging perposes :)\r
dw,bt:integer;\r
currentfdword:fdword;\r
socketcount : integer ; // for debugging perposes :)\r
dw,bt:integer;\r
currentfdword:fdword;\r
\r
//this one has to be kept public for now because lcorewsaasyncselect calls it\r
procedure connectionfailedhandler(error:word);\r
\r
//this one has to be kept public for now because lcorewsaasyncselect calls it\r
procedure connectionfailedhandler(error:word);\r
+\r
+ {public in tlasio, and can't be private in both places, so should be public here. \r
+ fixes delphi warning --beware}\r
+ {$ifdef win32}\r
+ procedure myfdclose(fd : integer); override;\r
+ function myfdwrite(fd: LongInt;const buf;size: LongInt):LongInt; override;\r
+ function myfdread(fd: LongInt;var buf;size: LongInt):LongInt; override;\r
+ {$endif}\r
+\r
private\r
{$ifdef ipv6}\r
isv6socket : boolean; //identifies if the socket is v6, set by bindsocket\r
private\r
{$ifdef ipv6}\r
isv6socket : boolean; //identifies if the socket is v6, set by bindsocket\r
\r
procedure connecttimeouthandler(sender:tobject);\r
procedure connectsuccesshandler;\r
\r
procedure connecttimeouthandler(sender:tobject);\r
procedure connectsuccesshandler;\r
- {$ifdef win32}\r
- procedure myfdclose(fd : integer); override;\r
- function myfdwrite(fd: LongInt;const buf;size: LongInt):LongInt; override;\r
- function myfdread(fd: LongInt;var buf;size: LongInt):LongInt; override;\r
- {$endif}\r
end;\r
tsocket=longint; // for compatibility with twsocket\r
\r
end;\r
tsocket=longint; // for compatibility with twsocket\r
\r
\r
\r
procedure tlsocket.connect;\r
\r
\r
procedure tlsocket.connect;\r
-var\r
- a:integer;\r
- ip:tbinip;\r
begin\r
if state <> wsclosed then close;\r
//prevtime := 0;\r
begin\r
if state <> wsclosed then close;\r
//prevtime := 0;\r
\r
procedure tlsocket.bindsocket;\r
var\r
\r
procedure tlsocket.bindsocket;\r
var\r
inAddrtemp:TInetSockAddrV;\r
inAddrtempx:{$ifdef win32}winsock.TSockaddr{$else}TInetSockAddrV{$endif} absolute inaddrtemp;\r
inaddrtempsize:integer;\r
inAddrtemp:TInetSockAddrV;\r
inAddrtempx:{$ifdef win32}winsock.TSockaddr{$else}TInetSockAddrV{$endif} absolute inaddrtemp;\r
inaddrtempsize:integer;\r
\r
procedure tlsocket.listen;\r
var\r
\r
procedure tlsocket.listen;\r
var\r
socktype:integer;\r
biniptemp:tbinip;\r
origaddr:thostname;\r
socktype:integer;\r
biniptemp:tbinip;\r
origaddr:thostname;\r
state := wsclosed; // then set this back as it was an undesired side effect of dup\r
\r
try\r
state := wsclosed; // then set this back as it was an undesired side effect of dup\r
\r
try\r
- yes := $01010101; {Copied this from existing code. Value is empiric,\r
- but works. (yes=true<>0) }\r
- no := 0;\r
+ yes := $01010101; {Copied this from existing code. Value is empiric,\r
+ but works. (yes=true<>0) }\r
+ no := 0;\r
+\r
if SetSocketOptions(fdhandlein, SOL_SOCKET, SO_REUSEADDR,yes,sizeof(yes))=-1 then begin\r
raise ESocketException.create('unable to set SO_REUSEADDR socket option');\r
end;\r
if SetSocketOptions(fdhandlein, SOL_SOCKET, SO_REUSEADDR,yes,sizeof(yes))=-1 then begin\r
raise ESocketException.create('unable to set SO_REUSEADDR socket option');\r
end;\r
if result > absoloutemaxs then begin\r
myfdclose(result);\r
a := result;\r
if result > absoloutemaxs then begin\r
myfdclose(result);\r
a := result;\r
raise esocketexception.create('file discriptor out of range: '+inttostr(a));\r
end;\r
end;\r
raise esocketexception.create('file discriptor out of range: '+inttostr(a));\r
end;\r
end;\r