Skip to content

Commit

Permalink
[backend] support a block=0 option in /lastevents
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed May 27, 2021
1 parent fbeaccf commit 7eff6c3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/backend/bs_srcserver
Original file line number Diff line number Diff line change
Expand Up @@ -5869,14 +5869,15 @@ sub lastevents {
my $ret = {'next' => $lastno, 'sync' => 'lost'};
return ($ret, $BSXML::events);
}
if (!$BSStdServer::isajax) {
my $block = !exists($cgi->{'block'}) || $cgi->{'block'};
if (!$BSStdServer::isajax && $block) {
my @args;
push @args, "obsname=$cgi->{'obsname'}" if $cgi->{'obsname'};
push @args, map {"filter=$_"} @{$filter || []};
push @args, "start=$cgi->{'start'}";
BSHandoff::handoff('/lastevents', undef, @args);
}
BSWatcher::addfilewatcher("$eventdir/lastevents", 120);
BSWatcher::addfilewatcher("$eventdir/lastevents", 120) if $BSStdServer::isajax;

my @s = stat("$eventdir/lastevents");
my @events;
Expand Down Expand Up @@ -5937,7 +5938,7 @@ sub lastevents {
# - survive history truncation
$cgi->{'start_orig'} ||= $cgi->{'start'};
$cgi->{'req_time'} ||= time();
if ($BSStdServer::isajax && !@events && $nextno < $cgi->{'start_orig'} + 100 && time() < $cgi->{'req_time'} + 300) {
if ($block && $BSStdServer::isajax && !@events && $nextno < $cgi->{'start_orig'} + 100 && time() < $cgi->{'req_time'} + 300) {
# small hack: update cgi to the next event number
$cgi->{'start'} = $nextno if $cgi->{'start'} < $nextno;
return undef;
Expand Down Expand Up @@ -7168,14 +7169,14 @@ my $dispatches = [
'/getsignkey $project withpubkey:bool? autoextend:bool? withalgo:bool?' => \&getsignkey,

# event/notification handling
'!- /lastevents $filter:* start:num? obsname:?' => \&lastevents,
'!- /lastevents $filter:* start:num? obsname:? block:bool?' => \&lastevents,
'!- /lasteventsproxy $filter:* start:num? remoteurl: client:?' => \&lasteventsproxy,
'/lastnotifications start:num? view:? block:bool? noprune:bool?' => \&lastnotifications,
'/notificationpayload/$payloadkey:filename' => \&getnotificationpayload,
'DELETE:/notificationpayload/$payloadkey:filename' => \&deletenotificationpayload,
'POST:/event type: project: package:? repository:? arch:? job:?' => \&newevent,
# tmp until lightty gets fixed
'/public/lastevents $filter:* start:num? obsname:?' => \&lastevents,
'/public/lastevents $filter:* start:num? obsname:? block:bool?' => \&lastevents,

# search interface
'/search $in: $match: return:? values:bool?' => \&search,
Expand Down

0 comments on commit 7eff6c3

Please sign in to comment.