viewing paste Unknown #1544 | Perl

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
use Perl::Unsafe::Signals;
sub AttemptNewRPCcLient { my ($sPeerAddr,$sPeerPort,$oSocket) = @_;
    my $i=0;
    my $oPlClient;
    while(!$oPlClient){
        print "Attempt to create a new RPC::PlClient \n";
        $| = 1;
        local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
        alarm 5;
        UNSAFE_SIGNALS {
             $oPlClient = new RPC::PlClient(     
                'peeraddr'    => $sPeerAddr,
                'peerport'    => $sPeerPort,
                'application' => "RemoteServiceAccess",
                'version'     => '1.0',
                'user'        => "",
                'password'    => "",
                'socket'      => $oSocket,
                'timeout'   => 10,
            );
        };
        alarm 0;        
        unless($oPlClient) { #no pl client
            warn "RPC creation failure reattemting creation nb=$i in 1s \n"; 
            sleep 1;
            $i++;
            if($i>=MAX_RPC_ATTEMPT){ 
                warn "Cannot create RPC Client \n";
                return 0;
            }
            next;
        }; 
    }
    print "Fin du new RPC::PlClient \n\n\n";
    return $oPlClient;
}
Viewed 1226 times, submitted by lighta.