index 029abcbf4105a3f231c4d0ac641f3009b08d49ac..d4297aac1f26d5f5158e2f7a69c0cee9b77e175e 100644 (file)
use GOSA::GosaSupportDaemon;
use threads;
use Time::HiRes qw(usleep);
-
+use utf8;
my $col_names = {};
my $class = shift;
my $db_name = shift;
- my $lock = $db_name.".gosa_lock";
+ my $lock = $db_name.".lock";
# delete existing lock - instance should be running only once
if(stat($lock)) {
unlink($lock);
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;
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;
}
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});
}
my $self = shift;
my $table_name = shift;
my $col_names_ref = shift;
+ my @col_names;
+ foreach my $col_name (@$col_names_ref) {
+ my @t = split(" ", $col_name);
+ $col_name = $t[0];
+ push(@col_names, $col_name);
+ }
+
$col_names->{ $table_name } = $col_names_ref;
- my $col_names_string = join(', ', @{$col_names_ref});
+ my $col_names_string = join(', ', @col_names);
my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name ( $col_names_string )";
&create_lock($self,'create_table');
$self->{dbh}->do($sql_statement);
# primekey is unique
# fetch column names of table
- my $col_names = &get_table_columns("",$table);
+ my $col_names = &get_table_columns($self, $table);
# assign values to column name variables
my @add_list;
foreach my $col_name (@{$col_names}) {
- # use function parameter for column values
+ # use function parameter for column values
+
if (exists $arg->{$col_name}) {
push(@add_list, $arg->{$col_name});
}
}
my $sql_statement = "INSERT INTO $table VALUES ('".join("', '", @add_list)."')";
-
&create_lock($self,'add_dbentry');
my $db_res = $self->{dbh}->do($sql_statement);
&remove_lock($self,'add_dbentry');
&create_lock($self,'get_table_columns');
my @res = @{$self->{dbh}->selectall_arrayref("pragma table_info('$table')")};
&remove_lock($self,'get_table_columns');
+
foreach my $column (@res) {
push(@column_names, @$column[1]);
}