X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fgosa-si-server;h=1dd69157831df62552ae5277a4f56412f38b6b34;hb=7067bdf5cb4d4f7fc5a303c9005c183baeccff67;hp=897aef8b6a23665f8f6ab0924b4af229b96d76f4;hpb=9b94861089e0927b96c6fe373653406ff565ae77;p=gosa.git diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 897aef8b6..1dd691578 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 } @@ -484,10 +485,6 @@ sub get_processing_child { $answer = $tmp; } } - - #&print_known_daemons(); - #&print_known_clients(); - daemon_log("processing of msg finished", 5); if (defined $answer) { @@ -498,7 +495,7 @@ sub get_processing_child { daemon_log("\n$answer", 7); } else { print $PARENT_wr "done"."\n"; - daemon_log(" ", 7); + print $PARENT_wr "ENDMESSAGE\n"; } redo; } @@ -756,41 +753,41 @@ sub create_known_client { return; } -sub sysreadline(*;$) { - my ($hd, $timeout) = @_; - - $hd = qualify_to_ref($hd, caller()); - my $infinitely_patient = (@_ == 1 || $timeout < 0); - my $start_time = time(); - my $selector = IO::Select->new(); - $selector->add($hd); - my $line = ""; - -SLEEP: - until( at_eol($line)) { - if (not $infinitely_patient) { - return $line if time() > ($start_time + $timeout); - } - next SLEEP unless $selector->can_read(1.0); -INPUT_READY: - while( $selector->can_read(0.0)) { - my $was_blocking = $hd->blocking(0); -CHAR: while (sysread($hd, my $nextbyte, 1)) { - $line .= $nextbyte; - last CHAR if $nextbyte eq "\n"; - - } - $hd->blocking($was_blocking); - next SLEEP unless at_eol($line); - last INPUT_READY; - } - } - return $line; -} - -sub at_eol($) { - $_[0] =~ /\n\z/ ; -} +#sub sysreadline(*;$) { +# my ($hd, $timeout) = @_; +# +# $hd = qualify_to_ref($hd, caller()); +# my $infinitely_patient = (@_ == 1 || $timeout < 0); +# my $start_time = time(); +# my $selector = IO::Select->new(); +# $selector->add($hd); +# my $line = ""; +# +#SLEEP: +# until( at_eol($line)) { +# if (not $infinitely_patient) { +# return $line if time() > ($start_time + $timeout); +# } +# next SLEEP unless $selector->can_read(1.0); +#INPUT_READY: +# while( $selector->can_read(0.0)) { +# my $was_blocking = $hd->blocking(0); +#CHAR: while (sysread($hd, my $nextbyte, 1)) { +# $line .= $nextbyte; +# last CHAR if $nextbyte eq "\n"; +# +# } +# $hd->blocking($was_blocking); +# next SLEEP unless at_eol($line); +# last INPUT_READY; +# } +# } +# return $line; +#} +# +#sub at_eol($) { +# $_[0] =~ /\n\z/ ; +#} #==== MAIN = main ============================================================== @@ -840,6 +837,8 @@ if( 0 != $pid ) { daemon_log(" ", 1); daemon_log("$0 started!", 1); +# delete old DBsqlite lock files +system('rm -f /tmp/gosa_si_lock*'); # connect to gosa-si job queue my @job_col_names = ("id", "timestamp", "status", "result", "headertag", "targettag", "xmlmessage", "macaddress"); @@ -981,30 +980,21 @@ while(1) { } chomp($in_msg); - daemon_log("process child read:", 7); - daemon_log("\n$in_msg", 7); if (not defined $in_msg) { next; } elsif ($in_msg =~ "done") { + daemon_log("process child read: $in_msg", 7); delete $busy_child{$pid}; $free_child{$pid} = $child_hash; } else { - print ">>>>>>>>>>>1\n"; + daemon_log("process child read:", 7); + daemon_log("\n$in_msg", 8); # send computed answer back to connected client my $act_client = $busy_child{$pid}{client_ref}; print $act_client $in_msg."\n"; - print ">>>>>>>>>>>2\n"; - - #my $act_pipe = $busy_child{$pid}{pipe_rd}; delete $busy_child{$pid}; $free_child{$pid} = $child_hash; - print ">>>>>>>>>>>3\n"; - - # give the client a chance to read - sleep(5); - close ($act_client); - print ">>>>>>>>>>>4\n"; } } @@ -1027,7 +1017,7 @@ while(1) { while( my ($id, $hit) = each %{$res} ) { - my $jobdb_id = $hit->{ROWID}; + my $jobdb_id = $hit->{id}; my $macaddress = $hit->{macaddress}; my $job_msg_hash = &transform_msg2hash($hit->{xmlmessage}); my $out_msg_hash = $job_msg_hash; @@ -1040,7 +1030,7 @@ while(1) { &daemon_log("xml message: $hit->{xmlmessage}", 5); my $update_hash = { table=>$job_queue_table_name, update=> [ { status=>['error'], result=>["no host found for mac address"] } ], - where=> [ { ROWID=>[$jobdb_id] } ], + where=> [ { id=>[$jobdb_id] } ], }; my $res = $job_db->update_dbentry($update_hash); @@ -1067,16 +1057,13 @@ while(1) { my $error = &send_msg_hash2address($out_msg_hash, "$gosa_ip:$gosa_port", $gosa_passwd); -####################### -# TODO exchange ROWID with jobid, insert column jobid in table jobs befor - if ($error == 0) { - my $sql = "UPDATE '$job_queue_table_name' SET status='processing', targettag='$target' WHERE ROWID='$jobdb_id'"; + my $sql = "UPDATE '$job_queue_table_name' SET status='processing', targettag='$target' WHERE id='$jobdb_id'"; my $res = $job_db->exec_statement($sql); } else { my $update_hash = { table=>$job_queue_table_name, update=> [ { status=>'error' } ], - where=> [ { ROWID=>$jobdb_id } ], + where=> [ { id=>$jobdb_id } ], }; my $res = $job_db->update_dbentry($update_hash); }