diff --git a/src/warden-server/lib/Warden.pm b/src/warden-server/lib/Warden.pm index 8faad079e8a24b476f03b3ae2482b046c99025bb..53f31bf882e11216d6d887912c2b7eb9078e17b9 100755 --- a/src/warden-server/lib/Warden.pm +++ b/src/warden-server/lib/Warden.pm @@ -33,7 +33,7 @@ our $DB_NAME = undef; our $DB_USER = undef; our $DB_PASS = undef; our $DB_HOST = undef; -our $MAX_EVENTS_LIMIT = undef; +our $MAX_EVENTS_LIMIT = undef; # server events limit our %VALID_STRINGS = undef; # load set variables by user @@ -135,7 +135,7 @@ sub authorizeClient ORDER BY SUBSTRING_INDEX(ip_net_client,'/', -1) DESC;"); } elsif($function_name eq 'getNewEvents') { $sth = $DBH->prepare("SELECT hostname, ip_net_client, receive_own_events - FROM clients WHERE hostname IN ($alt_names) AND type = ? AND client_type = ? + FROM clients WHERE hostname IN ($alt_names) AND (type = ? OR type = '_any_') AND client_type = ? ORDER BY SUBSTRING_INDEX(ip_net_client,'/', -1) DESC;"); } @@ -250,19 +250,22 @@ sub getNewEvents # parse SOAP data object my $requested_type = $data->{'REQUESTED_TYPE'} || '_any_'; my $last_id = $data->{'LAST_ID'}; - my $max_rcv_events_limit = $data->{'MAX_RCV_EVENTS_LIMIT'}; + my $max_rcv_events_limit = $data->{'MAX_RCV_EVENTS_LIMIT'}; # client events limit + + # comparison of client and server limit - which can be used + (defined $max_rcv_events_limit && $max_rcv_events_limit < $MAX_EVENTS_LIMIT) ? my $used_limit = $max_rcv_events_limit : my $used_limit = $MAX_EVENTS_LIMIT; my %client = authorizeClient($alt_names, $ip, $requested_type, $client_type, $function_name); if(defined %client) { - if ($client{'receive_own'} eq 't') { # check if client want your own events or not - if ($requested_type eq '_any_') { # check if client want each or only one type of messages + if ($client{'receive_own'} eq 't') { + if ($requested_type eq '_any_') { $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' ORDER BY id ASC LIMIT ?;"); if (!defined $sth) {die("Cannot prepare ROE-ANY statement in $function_name: $DBI::errstr\n")} - (defined $max_rcv_events_limit && $max_rcv_events_limit < $MAX_EVENTS_LIMIT) ? $sth->execute($last_id, $max_rcv_events_limit) : $sth->execute($last_id, $MAX_EVENTS_LIMIT); + my $rows = $sth->execute($last_id, $used_limit); } else { $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' ORDER BY id ASC LIMIT ?;"); if (!defined $sth) {die("Cannot prepare ROE statement in $function_name: $DBI::errstr\n")} - (defined $max_rcv_events_limit && $max_rcv_events_limit < $MAX_EVENTS_LIMIT) ? $sth->execute($last_id, $requested_type, $max_rcv_events_limit) : $sth->execute($last_id, $requested_type, $MAX_EVENTS_LIMIT); + my $rows = $sth->execute($last_id, $requested_type, $used_limit); } } else { if ($requested_type eq '_any_') { @@ -270,13 +273,13 @@ sub getNewEvents if (!defined $sth) {die("Cannot prepare ANY statement in $function_name: $DBI::errstr\n")} my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/; $domain = '\%' . $domain; - (defined $max_rcv_events_limit && $max_rcv_events_limit < $MAX_EVENTS_LIMIT) ? $sth->execute($last_id, $domain, $max_rcv_events_limit) : $sth->execute($last_id, $domain, $MAX_EVENTS_LIMIT); + my $rows = $sth->execute($last_id, $domain, $used_limit); } else { $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC LIMIT ?;"); if (!defined $sth) {die("Cannot prepare statement in $function_name: $DBI::errstr\n")} my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/; $domain = '\%' . $domain; - (defined $max_rcv_events_limit && $max_rcv_events_limit < $MAX_EVENTS_LIMIT) ? $sth->execute($last_id, $requested_type, $domain, $max_rcv_events_limit) : $sth->execute($last_id, $requested_type, $domain, $MAX_EVENTS_LIMIT); + my $rows = $sth->execute($last_id, $requested_type, $domain, $used_limit); } }