Code

periodic value within db should be 'none' or /d*_$periodic/
[gosa.git] / gosa-si / gosa-si-server
index 8e7f37918bb0331802da5a19d64f2114f7c1e6e5..1d59cd75ef7a83776f0ee1e0e48e4aed731be3cf 100755 (executable)
@@ -1140,7 +1140,15 @@ sub msg_to_decrypt {
        }
        # msg is from a gosa-si-client
        if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
-               ($msg, $msg_hash, $module) = &input_from_known_client($next_msg, $msg_source, $session_id);
+               if (not defined $msg_source) 
+               {
+                       # Only needed, to be compatible with older gosa-si-server versions
+                       ($msg, $msg_hash, $module) = &input_from_known_client($next_msg, $heap->{'remote_ip'}, $session_id);
+               }
+               else
+               {
+                       ($msg, $msg_hash, $module) = &input_from_known_client($next_msg, $msg_source, $session_id);
+               }
        }
        # an error occurred
        if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
@@ -1712,26 +1720,28 @@ sub watch_for_done_jobs {
 
        while( my ($number, $hit) = each %{$res} ) 
        {
+               # Non periodical jobs can be deleted.
+               if ($hit->{periodic} eq "none")
+               {
+                       my $jobdb_id = $hit->{id};
+                       my $sql_statement = "DELETE FROM $job_queue_tn WHERE id=$jobdb_id"; 
+                       my $res = $job_db->del_dbentry($sql_statement); 
+               }
+
                # Periodical jobs should not be deleted but reactivated with new timestamp instead.
-               if (exists $check_periodic->{$hit->{periodic}})
+               else
                {
+                       my ($p_time, $periodic) = split("_", $hit->{periodic});
                        my $reactivated_ts = $hit->{timestamp};
                        my $act_ts = int(&get_time());
                        while ($act_ts > int($reactivated_ts))   # Redo calculation to avoid multiple jobs in the past
                        {
-                               $reactivated_ts = &calc_timestamp($reactivated_ts, "plus", 1, $hit->{periodic});
+                               $reactivated_ts = &calc_timestamp($reactivated_ts, "plus", $p_time, $periodic);
                        }
                        my $sql = "UPDATE $job_queue_tn SET status='waiting', timestamp='$reactivated_ts' WHERE id='".$hit->{id}."'"; 
                        my $res = $job_db->exec_statement($sql);
                        &daemon_log("J INFO: Update periodical job '".$hit->{headertag}."' for client '".$hit->{targettag}."'. New execution time '$reactivated_ts'.", 5);
                }
-               # Non periodical jobs can be deleted.
-               else
-               {
-                       my $jobdb_id = $hit->{id};
-                       my $sql_statement = "DELETE FROM $job_queue_tn WHERE id=$jobdb_id"; 
-                       my $res = $job_db->del_dbentry($sql_statement); 
-               }
        }
 
        $kernel->delay_set('watch_for_done_jobs',$job_queue_loop_delay);