From fa0fdcb47aa1f589d876c5b55dfc42b606cea608 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Tue, 15 Jan 2008 18:37:21 +0000 Subject: [PATCH] server working atm git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8375 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 7 ++++--- gosa-si/modules/DBsqlite.pm | 23 +++++++++++++---------- gosa-si/tests/client.php | 8 ++++---- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 5ad1a8f3f..f0b59ce9c 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -42,6 +42,7 @@ use Cwd; use File::Spec; use GOSA::GosaSupportDaemon; use GOSA::DBsqlite; +use threads; my $modules_path = "/usr/lib/gosa-si/modules"; use lib "/usr/lib/gosa-si/modules"; @@ -192,7 +193,7 @@ sub read_configfile { # RETURNS: nothing # DESCRIPTION: function for logging #=============================================================================== -sub daemon_log { +sub daemon_log : locked { # log into log_file my( $msg, $level ) = @_; if(not defined $msg) { return } @@ -999,8 +1000,8 @@ while(1) { $free_child{$pid} = $child_hash; # give the client a chance to read - sleep(5); - close ($act_client); + #sleep(1); + #close ($act_client); } } diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 6f727b200..618dd00c7 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -5,9 +5,10 @@ use strict; use warnings; use DBI; use Data::Dumper; +use threads; +use Time::HiRes qw(usleep); my $col_names = {}; -my $checking=0; sub new { my $class = shift; @@ -27,31 +28,33 @@ sub new { return($self); } -sub lock_exists { - while($checking) { - sleep 1; - } - $checking=1; +sub lock_exists : locked { my $self=shift; my $funcname=shift; my $lock = $self->{db_lock}; my $result=(-f $lock); if($result) { print STDERR "(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock gefunden\n"; - sleep 2; + usleep 100; } - $checking=0; return $result; } -sub create_lock { +sub create_lock : locked { my $self=shift; my $funcname=shift; print STDERR "(".((defined $funcname)?$funcname:"").") Erzeuge Lock (PID ".$$.") ".($self->{db_lock})."\n"; + + my $lock = $self->{db_lock}; + while( -f $lock ) { + print STDERR "(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock gefunden\n"; + sleep 1; + } + open($self->{db_lock_handle},'>',$self->{db_lock}); } -sub remove_lock { +sub remove_lock : locked { my $self=shift; my $funcname=shift; print STDERR "(".((defined $funcname)?$funcname:"").") Entferne Lock (PID ".$$.") ".$self->{db_lock}."\n"; diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index 1d93746de..e3678623e 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -31,10 +31,10 @@ if($sock->connected()){ # clear #$data = "
gosa_clear_jobdb
"; - $sock->write($data); - - $answer = $sock->read(); - echo "$answer\n"; + $sock->write($data); + $answer = "nothing"; + $answer = $sock->read(); + echo ">>>$answer<<<\n"; $sock->close(); }else{ echo "... FAILED!\n"; -- 2.30.2