From f3e7191ae86b96a8551c7eff83ec7a604cf13e73 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 30 Jun 2017 08:41:34 +0000 Subject: [PATCH] TcpServerUtils.pm: avoid memory leak, delete attribtue for temprary connections (Forum #73490) git-svn-id: https://svn.fhem.de/fhem/trunk@14602 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/01_FHEMWEB.pm | 19 ++++++++----------- fhem/FHEM/TcpServerUtils.pm | 2 ++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 36a4eeef2..294885870 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -521,8 +521,8 @@ FW_Read($$) if(grep { $p->{$_}{FORKABLE} && $arg =~ m+^$FW_ME$_+ } keys %{$p}) { my $pid = fhemFork(); if($pid) { # success, parent - use constant PRIO_PROCESS => 0; - setpriority(PRIO_PROCESS, $pid, getpriority(PRIO_PROCESS,$pid) + $pf) + use constant PRIO_PROCESS => 0; + setpriority(PRIO_PROCESS, $pid, getpriority(PRIO_PROCESS,$pid) + $pf) if($^O !~ m/Win/); # a) while child writes a new request might arrive if client uses # pipelining or @@ -530,14 +530,15 @@ FW_Read($$) # to socket # -> have to close socket in parent... so that its only used in this # child. - TcpServer_Disown( $hash ); - delete($defs{$name}); + TcpServer_Disown( $hash ); + delete($defs{$name}); + delete($attr{$name}); FW_Read($hash, 1) if($hash->{BUF}); - return; + return; } elsif(defined($pid)){ # child delete $hash->{BUF}; - $hash->{isChild} = 1; + $hash->{isChild} = 1; } # fork failed and continue in parent } @@ -580,7 +581,6 @@ FW_Read($$) if(!$hash->{isChild}); TcpServer_Close( $hash ); FW_closeConn($hash); - delete($defs{$name}); } } @@ -706,7 +706,6 @@ FW_closeConn($) $FW_userAgent && $FW_userAgent=~m/(iPhone|iPad|iPod)/); if(!$FW_httpheader{Connection} || $cc) { TcpServer_Close($hash); - delete($defs{$hash->{NAME}}); } } @@ -2786,7 +2785,6 @@ FW_logInform($$) if(!FW_addToWritebuffer($ntfy, "