X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=helm%2Fhxsp%2Fsplitted%2F3.daemon.p.pl;fp=helm%2Fhxsp%2Fsplitted%2F3.daemon.p.pl;h=0000000000000000000000000000000000000000;hp=3e378733637ffdf628e4a8307cf5c38b65e3548d;hb=1696761e4b8576e8ed81caa905fd108717019226;hpb=5325734bc2e4927ed7ec146e35a6f0f2b49f50c1 diff --git a/helm/hxsp/splitted/3.daemon.p.pl b/helm/hxsp/splitted/3.daemon.p.pl deleted file mode 100644 index 3e3787336..000000000 --- a/helm/hxsp/splitted/3.daemon.p.pl +++ /dev/null @@ -1,131 +0,0 @@ -################################################################################################# -################################################################################################# -# HTTP::Daemon Operations -################################################################################################# -################################################################################################# - -# do not accumulate defunct processes -$SIG{CHLD} = "IGNORE"; -$SIG{USR1} = \&listen; # sent by the child to make the parent read the pipe - -pipe LIST_CHILD, TELL_PARENT; -pipe LIST_PARENT, TELL_CHILD; -TELL_PARENT->autoflush(1); -TELL_CHILD->autoflush(1); - - -sub listen { - my $res; - my $query = ; - if ($query =~ /^add /) { - $query =~ s/^add //; - chomp($query); - $res = add($query); - } - elsif ($query =~ /^reload /) { - $query =~ s/^reload //; - chomp($query); - $res = reload($query); - } - elsif ($query =~ /^remove /) { - $query =~ s/^remove //; - chomp($query); - $res = remove($query); - } - print TELL_CHILD "$res\n"; - print TELL_CHILD "____\n"; # end of response -} - -while (my $c = $d->accept) #connect -{ - if (fork() == 0) #start new concurrent process - { - while (my $r = $c->get_request) #get http request - { - if ($r->method eq 'GET' && - ($r->url->path eq $working_path or $r->url->path eq $working_path."/"))#start dir - { - my $response = new HTTP::Response; - $response->header('Cache-Control' => 'no-cache','Pragma' => "no-cache",'Expires' => '0'); - $response->content(home($r->url->query)); - $c->send_response($response); - } - elsif ($r->method eq 'GET' && $r->url->path eq $working_path."/help")#usage - { - my $response = new HTTP::Response; - $response->header('Cache-Control' => 'no-cache','Pragma' => "no-cache",'Expires' => '0'); - $response->content(help($r->url->query)); - $c->send_response($response); - } - elsif ($r->method eq 'GET' && $r->url->path eq $working_path."/add")#add - { - my $response = new HTTP::Response; - kill(USR1,getppid()); # ask the parent to read the pipe - my $qs = $r->url->query; - print TELL_PARENT "add $qs\n"; - my $in; - while (($in = ) ne "____\n") { - $res .= $in; - } - chomp($res); - $response->header('Cache-Control' => 'no-cache','Pragma' => "no-cache",'Expires' => '0'); - $response->content($res); - $c->send_response($response); - } - elsif ($r->method eq 'GET' && $r->url->path eq $working_path."/remove")#remove - { - my $response = new HTTP::Response; - kill(USR1,getppid()); # ask the parent to read the pipe - my $qs = $r->url->query; - print TELL_PARENT "remove $qs\n"; - my $in; - my $res=""; - while (($in = ) ne "____\n") { - $res .= $in; - } - chomp($res); - $response->content($res); - $response->header('Cache-Control' => 'no-cache','Pragma' => "no-cache",'Expires' => '0'); - $c->send_response($response); - } - elsif ($r->method eq 'GET' && $r->url->path eq $working_path."/reload")#reload - { - my $response = new HTTP::Response; - kill(USR1,getppid()); # ask the parent to read the pipe - my $qs = $r->url->query; - print TELL_PARENT "reload $qs\n"; - my $in; - my $res=""; - while (($in = ) ne "____\n") { - $res .= $in; - } - chomp($res); - $response->content($res); - $response->header('Cache-Control' => 'no-cache','Pragma' => "no-cache",'Expires' => '0'); - $c->send_response($response); - } - elsif ($r->method eq 'GET' && $r->url->path eq $working_path."/list")#list - { - my $response = new HTTP::Response; - $response->header('Cache-Control' => 'no-cache','Pragma' => "no-cache",'Expires' => '0'); - $response->content(list($r->url->query)); - $c->send_response($response); - } - elsif ($r->method eq 'GET' && $r->url->path eq $working_path."/apply")#apply - { - my %headers; - my $response = new HTTP::Response; - $response->content(apply($r->url->query,\%headers)); - $response->header(%headers); - $c->send_response($response); - } - else #wrong command or not working_path - { - $c->send_error(RC_FORBIDDEN) - } - } - $c->close; - undef($c); - exit; - } # fork -}