From: janw Date: Mon, 9 Mar 2009 09:36:16 +0000 (+0000) Subject: Changed open to sysopen. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=44040b3b5284ce1b1f8b267c51f9747992f01990;p=gosa.git Changed open to sysopen. More debugging messages about locking. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13511 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/trunk/gosa-si/modules/DBsqlite.pm b/trunk/gosa-si/modules/DBsqlite.pm index c1d7b84a6..ab66fce43 100644 --- a/trunk/gosa-si/modules/DBsqlite.pm +++ b/trunk/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,18 +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); }