1 # Copyright (C) 2002 Stanislav Sinyagin
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 # $Id: DB.pm,v 1.1 2012/01/08 23:58:23 root Exp root $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
19 # Dean Hamstead <dean@fragfest.com.au>
30 our $dbType; # this is set in torrus-config.pl or torrus-siteconfig.pl
37 my $location = "Torrus/DB/${dbType}.pm";
38 my $class = "Torrus::DB::$dbType";
42 return $class->new(@args)
46 # It is strongly inadvisable to do anything inside a signal handler when DB
47 # operation is in progress
51 my $signalHandlersSet = 0;
60 if( $signalHandlersSet )
68 Warn
('Received SIGTERM. Scheduling to exit.');
73 Warn
('Received SIGTERM. Stopping the process.');
81 Warn
('Received SIGINT. Scheduling to exit.');
86 Warn
('Received SIGINT. Stopping the process');
95 Warn
('Received SIGPIPE. Scheduling to exit.');
100 Warn
('Received SIGPIPE. Stopping the process');
108 Warn
('Received SIGQUIT. Scheduling to exit.');
113 Warn
('Received SIGQUIT. Stopping the process');
118 $signalHandlersSet = 1;
123 sub setSafeSignalHandlers
131 sub setUnsafeSignalHandlers
138 =head2 checkInterrupted
140 If we were previously interrupted, gracefully exit now
148 Warn
('Stopping the process');
158 die 'This should be implemented in the DB/Foo.pm package';
161 sub cleanupEnvironment
163 # this is pretty crappy but will do for now
164 # a better approach would be to use the objects and let them
165 # clean themselves when they are destroyed
166 for my $janitor (@Torrus::DB
::cleanUp
)
178 $self->{'delay_list_commit'} = 1;
185 die 'This should be implemented in the DB/Foo.pm package';
191 die 'This should be implemented in the DB/Foo.pm package';
196 die 'This should be implemented in the DB/Foo.pm package';
202 die 'This should be implemented in the DB/Foo.pm package';
208 die 'This should be implemented in the DB/Foo.pm package';
214 die 'This should be implemented in the DB/Foo.pm package';
219 die 'This should be implemented in the DB/Foo.pm package';
225 die 'This should be implemented in the DB/Foo.pm package';
230 die 'This should be implemented in the DB/Foo.pm package';
236 die 'This should be implemented in the DB/Foo.pm package';
242 die 'This should be implemented in the DB/Foo.pm package';
248 die 'This should be implemented in the DB/Foo.pm package';
254 die 'This should be implemented in the DB/Foo.pm package';
260 die 'This should be implemented in the DB/Foo.pm package';
266 die 'This should be implemented in the DB/Foo.pm package';
272 die 'This should be implemented in the DB/Foo.pm package';
278 die 'This should be implemented in the DB/Foo.pm package';
285 die 'This should be implemented in the DB/Foo.pm package';
291 die 'This should be implemented in the DB/Foo.pm package';
301 # indent-tabs-mode: nil
302 # perl-indent-level: 4