/[smeserver]/rpms/e-smith-backup/sme7/e-smith-backup-2.0.0-timeout.patch
ViewVC logotype

Annotation of /rpms/e-smith-backup/sme7/e-smith-backup-2.0.0-timeout.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Mon Oct 20 16:03:58 2008 UTC (15 years, 7 months ago) by slords
Branch: MAIN
CVS Tags: e-smith-backup-2_0_0-36_el4_sme, e-smith-backup-2_0_0-21_el4_sme, e-smith-backup-2_0_0-35_el4_sme, e-smith-backup-2_0_0-27_el4_sme, e-smith-backup-2_0_0-15_el4_sme, e-smith-backup-2_0_0-23_el4_sme, e-smith-backup-2_0_0-19_el4_sme, e-smith-backup-2_0_0-26_el4_sme, e-smith-backup-2_0_0-38_el4_sme, e-smith-backup-2_0_0-33_el4_sme, e-smith-backup-2_0_0-32_el4_sme, e-smith-backup-2_0_0-29_el4_sme, e-smith-backup-2_0_0-11_el4_sme, e-smith-backup-2_0_0-22_el4_sme, e-smith-backup-2_0_0-10_el4_sme, e-smith-backup-2_0_0-9_el4_sme, e-smith-backup-2_0_0-14_el4_sme, e-smith-backup-2_0_0-12_el4_sme, e-smith-backup-2_0_0-20_el4_sme, e-smith-backup-2_0_0-16_el4_sme, e-smith-backup-2_0_0-31_el4_sme, e-smith-backup-2_0_0-18_el4_sme, e-smith-backup-2_0_0-28_el4_sme, e-smith-backup-2_0_0-13_el4_sme, e-smith-backup-2_0_0-8_el4_sme, e-smith-backup-2_0_0-30_el4_sme, e-smith-backup-2_0_0-37_el4_sme, e-smith-backup-2_0_0-34_el4_sme, e-smith-backup-2_0_0-24_el4_sme, e-smith-backup-2_0_0-17_el4_sme, e-smith-backup-2_0_0-25_el4_sme, e-smith-backup-2_0_0-7_el4_sme, HEAD
Many fixes

1 slords 1.1 --- e-smith-backup-2.0.0/root/etc/e-smith/events/actions/workstation-backup-dar.timeout 2008-10-07 11:34:31.000000000 -0600
2     +++ e-smith-backup-2.0.0/root/etc/e-smith/events/actions/workstation-backup-dar 2008-10-20 09:32:14.000000000 -0600
3     @@ -30,6 +30,8 @@
4     use esmith::ConfigDB;
5    
6     sub ldie;
7     +sub start_dar_killer;
8     +sub run_backup;
9    
10     my $job = shift || 'DailyBackup';
11     my $report;
12     @@ -257,32 +259,7 @@
13    
14     # launching dar backup
15    
16     -$err = system("/usr/bin/timeout",
17     - "-s",
18     - "TERM",
19     - "$timeout",
20     - "/usr/bin/dar",
21     - "-c",
22     - "$tmpdir/$id/$bkname",
23     - split(/\s+/,$ref),
24     - "-B",
25     - "/etc/dar/$job.dcf");
26     -
27     -if ($err == 0)
28     -{
29     - $report .= "Backup completed successfully on temporary dir \n";
30     -}
31     -elsif ($err == 15)
32     -{
33     - $report .= "Partial backup stored on temp dir.\n"
34     - . " Session closed by timeout after $timeout seconds.\n"
35     - . "Not an error, backup process will continue next night.\n";
36     -}
37     -else
38     -{
39     - $err = $err >> 8;
40     - ldie("Dar error during backup : $err \n");
41     -}
42     +run_backup();
43    
44     if ($incnum == 0)
45     {
46     @@ -338,3 +315,63 @@
47     system("/bin/umount", "$mntdir") if $mntdone;
48     die($errmsg);
49     }
50     +
51     +sub start_dar_killer
52     +{
53     + my ($darpid, $gracetime) = @_;
54     + my $tick = $gracetime/10;
55     +
56     + my $killer = fork;
57     + return $killer if $killer;
58     +
59     + POSIX::setsid;
60     + chdir '/';
61     + #fork && exit;
62     +
63     + warn "Dar killer $$ started for PID $darpid with gracetime $gracetime\n";
64     + # wait for timeout or backup termination
65     + while ($tick > 0) {
66     + sleep 10;
67     + $tick--;
68     + exit unless (kill(0, $darpid));
69     + }
70     +
71     + if (kill(0, $darpid)) {
72     + do {
73     + warn "Cleanly stops $darpid dar process\n";
74     + } while (kill('QUIT', $darpid) != 1);
75     + }
76     + warn "Partial backup stored on backup workstation.\n",
77     + "Session cleanly closed by timeout after $timeout seconds.\n",
78     + "Not an error, backup process will continue next night.\n";
79     +
80     + exit;
81     +}
82     +
83     +sub run_backup
84     +{
85     + my $data = undef;
86     + my $pid = undef;
87     + my $killerpid = undef;
88     +
89     + eval {
90     + ($pid = open INPUT, "-|", "/usr/bin/dar", "--create", "$tmpdir/$id/$bkname", split(/\s+/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" );
91     + warn "Running dar backup with PID $pid\n";
92     +
93     + if ($pid) {
94     + $killerpid = start_dar_killer($pid, $timeout); }
95     + $data = do { local($/); <INPUT> };
96     + close(INPUT);
97     + };
98     + $report .= $data;
99     +
100     + if ($killerpid && kill(0, $killerpid)) {
101     + do {
102     + warn "Killing killer $killerpid\n";
103     + } while (kill(9, $killerpid) != 1);
104     +
105     + waitpid($killerpid, 0);
106     + }
107     +
108     + return;
109     +}

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed