Changeset 490 for trunk/dns-rpc.cgi


Ignore:
Timestamp:
04/09/13 15:18:00 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Tweak RPC to run as FastCGI, and add another config option to control
the number of requests to handle before respawning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns-rpc.cgi

    r486 r490  
    2424# don't remove!  required for GNU/FHS-ish install from tarball
    2525use lib '.';    ##uselib##
    26 
    27 use DNSDB;      # note we're not importing subs;  this lets us (ab)use the same sub names here for convenience
    28 use Data::Dumper;
    29 
     26use DNSDB;
     27
     28use FCGI;
    3029#use Frontier::RPC2;
    3130use Frontier::Responder;
     
    6968};
    7069
    71 my $res = Frontier::Responder->new(
     70my $reqcnt = 0;
     71
     72while (FCGI::accept >= 0) {
     73  my $res = Frontier::Responder->new(
    7274        methods => $methods
    7375        );
    7476
    75 # "Can't do that" errors
    76 if (!$dnsdb) {
    77   print "Content-type: text/xml\n\n".$res->{_decode}->encode_fault(5, $msg);
    78   exit;
    79 }
    80 ##fixme:  fail on missing rpcuser/rpcsystem args
    81 
    82 print $res->answer;
     77  # "Can't do that" errors
     78  if (!$dnsdb) {
     79    print "Content-type: text/xml\n\n".$res->{_decode}->encode_fault(5, $dnsdb->err);
     80  } else {
     81    print $res->answer;
     82  }
     83  last if $reqcnt++ > $dnsdb->{maxfcgi};
     84} # while FCGI::accept
     85
    8386
    8487exit;
     
    8891##
    8992
    90 # Utility subs
     93# Check RPC ACL
    9194sub _aclcheck {
    9295  my $subsys = shift;
Note: See TracChangeset for help on using the changeset viewer.