From: Rob H. <for...@us...> - 2003-04-01 02:46:39
|
Update of /cvsroot/sandweb/sandweb/lib/SandWeb In directory sc8-pr-cvs1:/tmp/cvs-serv10310/lib/SandWeb Modified Files: Repository.pm Shell.pm Log Message: made timeout a global option, now you can easily set a number of seconds in the sandweb.cfg and CLI ops will time out at that time ( prevents runaway CVS/SSH processes and such ). Default is 300 seconds ( 5 minutes ). Index: Repository.pm =================================================================== RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/Repository.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -U2 -r1.51 -r1.52 --- Repository.pm 3 Feb 2003 20:56:03 -0000 1.51 +++ Repository.pm 1 Apr 2003 02:46:26 -0000 1.52 @@ -184,4 +184,9 @@ my $system_password = $args{'system_password'} || ''; + # $system_timeout specified the max. amount of time to spend + # on a CLI operation + + my $system_timeout = $args{'system_timeout'} || ''; + # $ssh_bin specifies the path to the SSH binary @@ -211,4 +216,5 @@ 'system_username' => $system_username, 'system_password' => $system_password, + 'system_timeout' => $system_timeout, 'ssh_bin' => $ssh_bin, 'cvs_bin' => $cvs_bin, @@ -2401,4 +2407,5 @@ my $system_username = $self->get_system_username() || ''; my $system_password = $self->get_system_password() || ''; + my $system_timeout = $self->get_system_timeout() || ''; my $vcs_username = $self->get_vcs_username() || ''; my $vcs_password = $self->get_vcs_password() || ''; @@ -2426,4 +2433,5 @@ system_username => $system_username, system_password => $system_password, + system_timeout => $system_timeout, vcs_username => $vcs_username, vcs_password => $vcs_password, @@ -2923,4 +2931,40 @@ return 0; } +} + +=head1 + +METHOD + + get_system_timeout + +SYNOPSIS + + my $return_code = $CVS->get_system_timeout(); + +DESCRIPTION + + Returns the current timeout setting for CLI operations ( in seconds ). + +PARAMETERS + + None + +RETURN CODE + + A string containing the current timeout in seconds is returned. + + 0 = This means that the method got an error proccessing your request. + Perhaps an invalid parameter? + + -1 = This return value means that there was not sufficient permision to + read the files specified, or they did not exist. + + +=cut + +sub get_system_timeout { + my $self = shift; + return $self->{'system_timeout'}; } Index: Shell.pm =================================================================== RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/Shell.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -U2 -r1.31 -r1.32 --- Shell.pm 1 Feb 2003 03:42:43 -0000 1.31 +++ Shell.pm 1 Apr 2003 02:46:27 -0000 1.32 @@ -51,11 +51,4 @@ use SandWeb::File; -# -# FIXME - timeout should be a global config option -# -# default timeout for shell commands is 300 minutes ( aka 5 minutes ) -# -my $timeout = '300'; - =head1 @@ -72,4 +65,5 @@ 'system_username' => "$system_username", 'system_password' => "$system_password", + 'system_timeout' => "$system_timeout", 'bindir' => "$bindir", 'system' => "$system", @@ -102,4 +96,11 @@ Default: none. + system_timeout (type: string) (optional) + + the global timeout value for CLI operations + + Default: none. + + vcs_username (type: string) (optional) @@ -160,4 +161,7 @@ my $system_password = $args{'system_password'} || ''; + # system_password is the user's password on the local box ( optional ) + my $system_timeout = $args{'system_timeout'} || ''; + # users_dir is the user's SandWeb home directory ( required ) my $users_dir = $args{'users_dir'} || ''; @@ -186,4 +190,5 @@ 'system_username' => "$system_username", 'system_password' => "$system_password", + 'system_timeout' => "$system_timeout", 'users_dir' => "$users_dir", 'vcs_username' => "$vcs_username", @@ -251,4 +256,5 @@ my $system_username = $self->{'system_username'}; my $system_password = $self->{'system_password'}; + my $system_timeout = $self->{'system_timeout'}; my $vcs_username = $self->{'vcs_username'}; my $vcs_password = $self->{'vcs_password'}; @@ -272,12 +278,12 @@ eval { local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; - my $raw_output = `$sandweb_expect system_vcs $system_username \'$system_password\' \'$vcs_password\' "$command" 2>&1` or $raw_output = "Timeout of $timeout seconds reached.\n"; + alarm $system_timeout; + my $raw_output = `$sandweb_expect system_vcs $system_username \'$system_password\' \'$vcs_password\' "$command" 2>&1` or $raw_output = "Timeout of $system_timeout seconds reached.\n"; alarm 0; }; - if ( "$@" eq "alarm" ) { + if ( "$@" ) { my $output = ""; - my $error_message = "Timeout reached of $timeout seconds reached, operation aborted.\n"; + my $error_message = "Timeout reached of $system_timeout seconds reached, operation aborted.\n"; my %return = ( @@ -301,13 +307,13 @@ eval { local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; - my $raw_output = `$sandweb_expect system $system_username $system_password $command` or $raw_output = "Timeout of $timeout seconds reached.\n"; + alarm $system_timeout; + my $raw_output = `$sandweb_expect system $system_username $system_password $command` or $raw_output = "Timeout of $system_timeout seconds reached.\n"; alarm 0; }; - if ( "$@" eq "alarm" ) { + if ( "$@" ) { my $output = ""; - my $error_message = "Timeout reached of $timeout seconds reached, operation aborted.\n"; + my $error_message = "Timeout reached of $system_timeout seconds reached, operation aborted.\n"; my %return = ( @@ -349,5 +355,5 @@ eval { local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; + alarm $system_timeout; my $error_output; $raw_output = `$sandweb_expect vcs $users_dir/passwd "$command" 2>&1`; @@ -357,8 +363,8 @@ }; - if ( "$@" eq "alarm" ) { + if ( "$@" ) { my $output = ""; - my $error_message = "Timeout reached of $timeout seconds reached, operation aborted.\n"; + my $error_message = "Timeout reached of $system_timeout seconds reached, operation aborted.\n"; my %return = ( @@ -393,13 +399,13 @@ eval { local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; - $output = `$command 2>&1` or $raw_output = "Timeout of $timeout seconds reached.\n"; + alarm $system_timeout; + $output = `$command 2>&1` or $raw_output = "Timeout of $system_timeout seconds reached.\n"; }; - if ( "$@" eq "alarm" ) { + if ( "$@" ) { my $output = ""; - my $error_message = "Timeout reached of $timeout seconds reached, operation aborted.\n"; + my $error_message = "Timeout reached of $system_timeout seconds reached, operation aborted.\n"; my %return = ( @@ -473,4 +479,6 @@ my %args = @_; + my $system_timeout = $self{'system_timeout'}; + my $log = $self->{'log'} || ''; @@ -480,10 +488,10 @@ eval { local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; + alarm $system_timeout; open (FILEHANDLE, "|`$command`") or return 0; alarm 0; }; - if ( "$@" eq "alarm" ) { + if ( "$@" ) { return 0; } |