From: janw Date: Mon, 9 Mar 2009 10:45:07 +0000 (+0000) Subject: Merged changeset:13511 from gosa-lhm. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=dbe1077cc255817248e557b16bcb6d4b865f6836;p=gosa.git Merged changeset:13511 from gosa-lhm. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13512 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 375111658..ab66fce43 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -7,7 +7,7 @@ use DBI; use Data::Dumper; use GOSA::GosaSupportDaemon; use Time::HiRes qw(usleep); -use Fcntl ':flock'; # import LOCK_* constants +use Fcntl qw/:DEFAULT :flock/; # import LOCK_* constants my $col_names = {}; @@ -40,17 +40,20 @@ sub new { sub lock { my $self = shift; - open($self->{db_lock_handle}, ">>".($self->{db_lock})) unless ref $self->{db_lock_handle}; - flock($self->{db_lock_handle},LOCK_EX); + if(not ref $self->{db_lock_handle}) { + sysopen($self->{db_lock_handle}, $self->{db_lock}, O_RDWR|O_CREAT, 0600) or &main::daemon_log("0 ERROR: Opening the lockfile for database ".$self->{db_name}." failed with $!", 1); + } + flock($self->{db_lock_handle}, LOCK_EX); seek($self->{db_lock_handle}, 0, 2); - chown($main::root_uid, $main::adm_gid, $self->{db_lock_handle}); - chmod(0640, $self->{db_lock_handle}); } sub unlock { my $self = shift; - flock($self->{db_lock_handle},LOCK_UN); + if(not ref $self->{db_lock_handle}) { + &main::daemon_log("0 BIG ERROR: Lockfile for databse ".$self->{db_name}."got closed within critical section!", 1); + } + flock($self->{db_lock_handle}, LOCK_UN); }