From 180195c38b58b9c63b5842eb324af5de8e92ffa1 Mon Sep 17 00:00:00 2001 From: janw Date: Mon, 28 Jan 2008 08:16:38 +0000 Subject: [PATCH] Added verbosity. Removed misplaced sleep. Added checks. Added another job. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8613 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 2 -- gosa-si/modules/DBsqlite.pm | 27 +++++++++------------------ gosa-si/modules/GosaSupportDaemon.pm | 2 +- gosa-si/tests/client.php | 3 ++- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index c5fe3a1b4..c631b814e 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -414,8 +414,6 @@ sub client_input { } daemon_log("processing of msg finished", 5); - sleep(10); - if (defined $answer) { $heap->{client}->put($answer); } else { diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 5f7fb0683..69dfe4e6c 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -5,6 +5,7 @@ use strict; use warnings; use DBI; use Data::Dumper; +use GOSA::GosaSupportDaemon; use threads; use Time::HiRes qw(usleep); @@ -36,7 +37,7 @@ sub lock_exists : locked { my $lock = $self->{db_lock}; my $result=(-f $lock); if($result) { - #print STDERR "(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock gefunden\n"; + &main::daemon_log("(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock gefunden", 6); usleep 100; } return $result; @@ -45,11 +46,11 @@ sub lock_exists : locked { sub create_lock : locked { my $self=shift; my $funcname=shift; - #print STDERR "(".((defined $funcname)?$funcname:"").") Erzeuge Lock (PID ".$$.") ".($self->{db_lock})."\n"; + &main::daemon_log("(".((defined $funcname)?$funcname:"").") Erzeuge Lock (PID ".$$.") ".($self->{db_lock}),6); my $lock = $self->{db_lock}; while( -f $lock ) { - #print STDERR "(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock gefunden\n"; + print STDERR "(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock gefunden\n"; sleep 1; } @@ -59,7 +60,7 @@ sub create_lock : locked { sub remove_lock : locked { my $self=shift; my $funcname=shift; - #print STDERR "(".((defined $funcname)?$funcname:"").") Entferne Lock (PID ".$$.") ".$self->{db_lock}."\n"; + &main::daemon_log("(".((defined $funcname)?$funcname:"").") Entferne Lock (PID ".$$.") ".$self->{db_lock}, 6); close($self->{db_lock_handle}); unlink($self->{db_lock}); } @@ -231,7 +232,9 @@ sub show_table { #&remove_lock($self,'show_table'); my $sql_statement= "SELECT * FROM $table_name ORDER BY timestamp"; + &create_lock($self,'show_table'); my $res= &exec_statement($self, $sql_statement); + &remove_lock($self,'show_table'); my @answer; foreach my $hit (@{$res}) { @@ -259,24 +262,12 @@ sub count_dbentries { my $answer= -1; my $sql_statement= "SELECT * FROM $table"; + &create_lock($self,'count_dbentries'); my $db_answer= &select_dbentry($self, $sql_statement); + &remove_lock($self, 'count_dbentries'); my $count = keys(%{$db_answer}); return $count; } -sub get_time { - my ($seconds, $minutes, $hours, $monthday, $month, - $year, $weekday, $yearday, $sommertime) = localtime(time); - $hours = $hours < 10 ? $hours = "0".$hours : $hours; - $minutes = $minutes < 10 ? $minutes = "0".$minutes : $minutes; - $seconds = $seconds < 10 ? $seconds = "0".$seconds : $seconds; - $month+=1; - $month = $month < 10 ? $month = "0".$month : $month; - $monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday; - $year+=1900; - return "$year$month$monthday$hours$minutes$seconds"; -} - - 1; diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index 182e920bf..496ce8d4e 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -320,7 +320,7 @@ sub get_where_statement { my $error= 0; my $clause_str= ""; - if( not exists @{$msg_hash->{'where'}}[0]->{'clause'} ) { $error++; }; + if( (not exists $msg_hash->{'where'}) || (not exists @{$msg_hash->{'where'}}[0]->{'clause'}) ) { $error++; }; if( $error == 0 ) { my @clause_l; my @where = @{@{$msg_hash->{'where'}}[0]->{'clause'}}; diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index e5590bd47..b1231b04a 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -30,7 +30,8 @@ if($sock->connected()){ # query #$data = "
gosa_query_jobdb
andgt0le5
"; #$data= "
gosa_query_jobdb
ping03
"; -$data= "
gosa_query_jobdb
ping05timestamp
"; +#$data= "
gosa_query_jobdb
ping05timestamp
"; +$data= "
gosa_query_jobdb
"; # count -- 2.30.2