svn commit: samba r24901 - in branches/SAMBA_4_0: . source/selftest/env

jelmer at samba.org jelmer at samba.org
Sun Sep 2 17:47:35 GMT 2007


Author: jelmer
Date: 2007-09-02 17:47:35 +0000 (Sun, 02 Sep 2007)
New Revision: 24901

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24901

Log:
Somewhat easier and more reliable access to the pid files.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/selftest/env/Samba3.pm


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/selftest/env/Samba3.pm
===================================================================
--- branches/SAMBA_4_0/source/selftest/env/Samba3.pm	2007-09-02 17:27:40 UTC (rev 24900)
+++ branches/SAMBA_4_0/source/selftest/env/Samba3.pm	2007-09-02 17:47:35 UTC (rev 24901)
@@ -34,9 +34,14 @@
 {
 	my ($self, $envvars) = @_;
 
-	$self->samba3_stop_sig_term($envvars->{PIDDIR});
-	$self->samba3_stop_sig_kill($envvars->{PIDDIR});
+	my $smbdpid = read_pid($envvars, "smbd");
+	my $nmbdpid = read_pid($envvars, "nmbd");
 
+	$self->stop_sig_term($smbdpid);
+	$self->stop_sig_term($nmbdpid);
+	$self->stop_sig_kill($smbdpid);
+	$self->stop_sig_kill($nmbdpid);
+
 	return 0;
 }
 
@@ -105,23 +110,33 @@
 	my ($self) = @_;
 }
 
-sub samba3_stop_sig_term($$) {
-	my ($self, $piddir) = @_;
-	my $ret = 0;
-	kill("USR1", `cat $piddir/timelimit.nmbd.pid`) or \
-		kill("ALRM", `cat $piddir/timelimit.nmbd.pid`) or $ret++;
+sub stop_sig_term($$) {
+	my ($self, $pid) = @_;
+	kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
+}
 
-	kill("USR1", `cat $piddir/timelimit.smbd.pid`) or \
-		kill("ALRM", `cat $piddir/timelimit.smbd.pid`) or $ret++;
+sub stop_sig_kill($$) {
+	my ($self, $pid) = @_;
+	kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
+}
 
-	return $ret;
+sub write_pid($$$)
+{
+	my ($env_vars, $app, $pid) = @_;
+
+	open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
+	print PID $pid;
+	close(PID);
 }
 
-sub samba3_stop_sig_kill($$) {
-	my ($self, $piddir) = @_;
-	kill("ALRM", `cat $piddir/timelimit.nmbd.pid`); 
-	kill("ALRM", `cat $piddir/timelimit.smbd.pid`);
-	return 0;
+sub read_pid($$)
+{
+	my ($env_vars, $app) = @_;
+
+	open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
+	my $pid = <PID>;
+	close(PID);
+	return $pid;
 }
 
 sub check_or_start($$$$) {
@@ -135,11 +150,9 @@
 		open STDERR, '>&STDOUT';
 	
 		$ENV{MAKE_TEST_BINARY} = $self->binpath("nmbd");
-		exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("nmbd"), "-F", "-S", "--no-process-group", "-d0" ,"-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start nmbd: $!");
+		exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("nmbd"), "-F", "-S", "-d0", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start nmbd: $!");
 	}
-	open(PID, ">$env_vars->{PIDDIR}/timelimit.nmbd.pid");
-	print PID $pid;
-	close(PID);
+	write_pid($env_vars, "nmbd", $pid);
 	print "DONE\n";
 
 	unlink($env_vars->{SMBD_TEST_LOG});
@@ -150,11 +163,9 @@
 		open STDERR, '>&STDOUT';
 	
 		$ENV{MAKE_TEST_BINARY} = $self->binpath("smbd");
-		exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("smbd"), "-F", "-S", "--no-process-group", "-d0" ,"-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start smbd: $!");
+		exec($self->binpath("timelimit"), $nmbd_maxtime, $self->binpath("smbd"), "-F", "-S", "-d0" , "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}) or die("Unable to start smbd: $!");
 	}
-	open(PID, ">$env_vars->{PIDDIR}/timelimit.smbd.pid");
-	print PID $pid;
-	close(PID);
+	write_pid($env_vars, "smbd", $pid);
 	print "DONE\n";
 
 	return 0;



More information about the samba-cvs mailing list