From caf8b80556029a88b370718179f01fa1dea35926 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Tue, 12 Feb 2008 15:46:36 +0000 Subject: [PATCH] bugfix: handling answers of gosa-si-server modules like SI- or GosaPackages git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8875 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 78 ++++++++++++++++++++----------------- gosa-si/modules/DBsqlite.pm | 8 ++-- 2 files changed, 47 insertions(+), 39 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index e4df616d2..04063e6f3 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -382,40 +382,40 @@ sub check_key_and_xml_validity { eval{ $msg = &decrypt_msg($crypted_msg, $module_key); - if ($msg =~ //i){ - &main::daemon_log("decrypted_msg: \n$msg", 8); - $msg_hash = $xml->XMLin($msg, ForceArray=>1); - - # check header - my $header_l = $msg_hash->{'header'}; - if( 1 != @{$header_l} ) { - die 'header error'; - } - my $header = @{$header_l}[0]; - if( 0 == length $header) { - die 'header error'; - } + if ($msg =~ //i){ + &main::daemon_log("decrypted_msg: \n$msg", 8); + $msg_hash = $xml->XMLin($msg, ForceArray=>1); + + # check header + my $header_l = $msg_hash->{'header'}; + if( 1 != @{$header_l} ) { + die 'header error'; + } + my $header = @{$header_l}[0]; + if( 0 == length $header) { + die 'header error'; + } - # check source - my $source_l = $msg_hash->{'source'}; - if( not defined @{$source_l} or 1 != @{$source_l} ) { - die 'source error'; - } - my $source = @{$source_l}[0]; - if( 0 == length $source) { - die 'source error'; - } + # check source + my $source_l = $msg_hash->{'source'}; + if( not defined @{$source_l} or 1 != @{$source_l} ) { + die 'source error'; + } + my $source = @{$source_l}[0]; + if( 0 == length $source) { + die 'source error'; + } - # check target - my $target_l = $msg_hash->{'target'}; - if( 1 != @{$target_l} ) { - die'target error'; - } - my $target = @{$target_l}[0]; - if( 0 == length $target) { - die 'target error'; - } - } + # check target + my $target_l = $msg_hash->{'target'}; + if( 1 != @{$target_l} ) { + die'target error'; + } + my $target = @{$target_l}[0]; + if( 0 == length $target) { + die 'target error'; + } + } }; if($@) { &main::daemon_log("WARNING: do not understand the message", 5); @@ -786,7 +786,7 @@ sub send_msg_to_target { $act_status = $res->{1}->{'status'}; if( $act_status eq "down" ) { $sql_statement = "DELETE FROM known_server WHERE hostname='$address'"; - $res = $known_clients_db->del_dbentry($sql_statement); + $res = $known_server_db->del_dbentry($sql_statement); daemon_log("WARNING: failed 2x to a send msg to host '$address', delete host from known_server", 3); } else { @@ -957,8 +957,16 @@ sub client_input { daemon_log("INFO: try to forward msg '$answer_header' to bus '$bus_address'", 5); my $sql_statement = "SELECT * FROM known_server WHERE hostname='$bus_address'"; my $query_res = $known_server_db->select_dbentry( $sql_statement ); - my $bus_key = $query_res->{1}->{hostkey}; - &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header); + my $res_length = keys( %{$query_res} ); + if( $res_length == 0 ){ + daemon_log("WARNING: send '$answer_header' to '$bus_address' failed, no bus found in known_server", 3); + } + else { + while( my ($hit_num, $hit) = each %{ $query_res } ) { + my $bus_key = $hit->{hostkey}; + &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header); + } + } } next; } diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 029abcbf4..206620c7c 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -38,7 +38,7 @@ sub lock_exists : locked { my $lock = $self->{db_lock}; my $result=(-f $lock); if($result) { - &main::daemon_log("(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock found", 8); + #&main::daemon_log("(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock found", 8); usleep 100; } return $result; @@ -47,11 +47,11 @@ sub lock_exists : locked { sub create_lock : locked { my $self=shift; my $funcname=shift; - &main::daemon_log("(".((defined $funcname)?$funcname:"").") Creating Lock (PID ".$$.") ".($self->{db_lock}),8); + #&main::daemon_log("(".((defined $funcname)?$funcname:"").") Creating Lock (PID ".$$.") ".($self->{db_lock}),8); my $lock = $self->{db_lock}; while( -f $lock ) { - &main::daemon_log("(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock found",8); + #&main::daemon_log("(".((defined $funcname)?$funcname:"").") Lock (PID ".$$.") $lock found",8); sleep 1; } @@ -61,7 +61,7 @@ sub create_lock : locked { sub remove_lock : locked { my $self=shift; my $funcname=shift; - &main::daemon_log("(".((defined $funcname)?$funcname:"").") Removing Lock (PID ".$$.") ".$self->{db_lock}, 8); + #&main::daemon_log("(".((defined $funcname)?$funcname:"").") Removing Lock (PID ".$$.") ".$self->{db_lock}, 8); close($self->{db_lock_handle}); unlink($self->{db_lock}); } -- 2.30.2