mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-17 05:16:02 +00:00
Closing old TCP connections
git-svn-id: https://svn.fhem.de/fhem/trunk@2147 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2d4ed0a88f
commit
4362eccf37
@ -15,6 +15,7 @@
|
|||||||
- change: added GPLv2 licensing information
|
- change: added GPLv2 licensing information
|
||||||
- bugfix: FHEMWEB slider with min > 0
|
- bugfix: FHEMWEB slider with min > 0
|
||||||
- change: FHEMWEB CORS moved to options
|
- change: FHEMWEB CORS moved to options
|
||||||
|
- change: FHEMWEB closing old TCP connections
|
||||||
|
|
||||||
- 2012-10-28 (5.3)
|
- 2012-10-28 (5.3)
|
||||||
- feature: added functions trim, ltrim, rtrim, UntoggleDirect,
|
- feature: added functions trim, ltrim, rtrim, UntoggleDirect,
|
||||||
|
@ -136,6 +136,7 @@ FHEMWEB_Initialize($)
|
|||||||
|
|
||||||
addToAttrList("webCmd");
|
addToAttrList("webCmd");
|
||||||
addToAttrList("icon");
|
addToAttrList("icon");
|
||||||
|
InternalTimer(time()+60, "FW_closeOldClients", 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -244,6 +245,7 @@ FW_Read($)
|
|||||||
|
|
||||||
@FW_httpheader = split("[\r\n]", $hash->{BUF});
|
@FW_httpheader = split("[\r\n]", $hash->{BUF});
|
||||||
|
|
||||||
|
|
||||||
my @origin = grep /Origin/, @FW_httpheader;
|
my @origin = grep /Origin/, @FW_httpheader;
|
||||||
$FW_headercors = (AttrVal($FW_wname, "CORS", 0) ?
|
$FW_headercors = (AttrVal($FW_wname, "CORS", 0) ?
|
||||||
"Access-Control-Allow-".$origin[0]."\r\n".
|
"Access-Control-Allow-".$origin[0]."\r\n".
|
||||||
@ -292,9 +294,11 @@ FW_Read($)
|
|||||||
}
|
}
|
||||||
#############################
|
#############################
|
||||||
|
|
||||||
|
my $now = time();
|
||||||
@FW_enc = grep /Accept-Encoding/, @FW_httpheader;
|
@FW_enc = grep /Accept-Encoding/, @FW_httpheader;
|
||||||
my ($mode, $arg, $method) = split(" ", $FW_httpheader[0]);
|
my ($mode, $arg, $method) = split(" ", $FW_httpheader[0]);
|
||||||
$hash->{BUF} = "";
|
$hash->{BUF} = "";
|
||||||
|
$hash->{LASTACCESS} = $now;
|
||||||
|
|
||||||
$arg = "" if(!defined($arg));
|
$arg = "" if(!defined($arg));
|
||||||
Log $ll, "HTTP $name GET $arg";
|
Log $ll, "HTTP $name GET $arg";
|
||||||
@ -319,7 +323,7 @@ FW_Read($)
|
|||||||
|
|
||||||
my $length = length($FW_RET);
|
my $length = length($FW_RET);
|
||||||
my $expires = ($cacheable?
|
my $expires = ($cacheable?
|
||||||
("Expires: ".localtime(time()+900)." GMT\r\n") : "");
|
("Expires: ".localtime($now+900)." GMT\r\n") : "");
|
||||||
Log $ll, "$arg / RL: $length / $FW_RETTYPE / $compressed / $expires";
|
Log $ll, "$arg / RL: $length / $FW_RETTYPE / $compressed / $expires";
|
||||||
print $c "HTTP/1.1 200 OK\r\n",
|
print $c "HTTP/1.1 200 OK\r\n",
|
||||||
"Content-Length: $length\r\n",
|
"Content-Length: $length\r\n",
|
||||||
@ -2519,7 +2523,6 @@ FW_Get($@)
|
|||||||
|
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
|
|
||||||
sub
|
sub
|
||||||
FW_Set($@)
|
FW_Set($@)
|
||||||
{
|
{
|
||||||
@ -2534,6 +2537,20 @@ FW_Set($@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
|
sub
|
||||||
|
FW_closeOldClients()
|
||||||
|
{
|
||||||
|
my $now = time();
|
||||||
|
foreach my $dev (keys %defs) {
|
||||||
|
next if(!$defs{$dev}{TYPE} || $defs{$dev}{TYPE} ne "FHEMWEB" ||
|
||||||
|
!$defs{$dev}{LASTACCESS} || $defs{$dev}{inform} ||
|
||||||
|
($now - $defs{$dev}{LASTACCESS}) < 60);
|
||||||
|
Log 4, "Closing connection $dev";
|
||||||
|
FW_Undef($defs{$dev}, "");
|
||||||
|
delete $defs{$dev};
|
||||||
|
}
|
||||||
|
InternalTimer($now+60, "FW_closeOldClients", 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user