in reply to Multithreaded Socket Listener
I know it's a big piece of code and looks ugly here. Sorry for this. If somebody has a hint for me - I would be very thankful :O)
It looks ugly anywhere :) seriously, subroutines should (for the most part) take arguments, not operate on global variables
You need more subroutines, there is way too much code outside of subroutines.
Instead of # build a list of files to check you need my @resultfiles = files_to_check( $properties );
Your code contains exit 18 times -- way too many,
Your loop should be short, like
while( $client = $server->accept() ) { if( my $pid = fork() ){ $logger->debug( "this is parent process closing client now" ); $client->close(); $logger->debug( "parent closed client" ); } else { KidStuff( $client , $logger, $pid, ... ); } }
This might interest you A suicidal parent OR death of a forking server
That's about all I got, except, you say you're using a browser -- then you might as well use write a plain old "CGI" PSGI, say with cgi-app / mojo / dancer / catalyst... and make it multithreaded with Perlbal or any other applicable server (feature of PSGI), instead of reinventing this particular wheel
Also, see Proc::Background :)
|
|---|