TT#98650 ?suppress_flush=1 parameter

suppress executing "ul.flush" kamailio xmlrpc after
"ul.add" or "ul.rm", as it seems to be another source of timeouts.

Change-Id: I8faf907c4cbfd6adbe3e3645f5c32069df2eb999
(cherry picked from commit 186ddabb17)
mr7.5.8
Rene Krenn 5 years ago
parent f240377320
commit 26d68bec2a

@ -154,11 +154,15 @@ sub POST :Allow {
last unless $txn_ok; last unless $txn_ok;
$item = $self->fetch_item($c, $resource, $form, $item); $item = $self->fetch_item($c, $resource, $form, $item);
last unless $item;
$c->response->status(HTTP_CREATED); if ($item) {
$c->response->header(Location => sprintf('/%s%s', $c->request->path, $item->id)); $c->response->status(HTTP_CREATED);
$c->response->body(q()); $c->response->header(Location => sprintf('/%s%s', $c->request->path, $item->id));
$c->response->body(q());
} else {
$c->response->status(HTTP_CREATED);
$c->response->body(q());
}
} }
return; return;
} }

@ -96,22 +96,26 @@ sub PATCH :Allow {
last unless $txn_ok; last unless $txn_ok;
$item = $self->fetch_item($c, $resource, $form, $item); $item = $self->fetch_item($c, $resource, $form, $item);
last unless $item;
if ('minimal' eq $preference) { if ($item) {
$c->response->status(HTTP_NO_CONTENT); if ('minimal' eq $preference) {
$c->response->header(Preference_Applied => 'return=minimal'); $c->response->status(HTTP_NO_CONTENT);
$c->response->header(Location => sprintf('%s%s', $self->dispatch_path, $item->id)); $c->response->header(Preference_Applied => 'return=minimal');
$c->response->body(q()); $c->response->header(Location => sprintf('%s%s', $self->dispatch_path, $item->id));
$c->response->body(q());
} else {
my $hal = $self->hal_from_item($c, $item, $form);
my $response = HTTP::Response->new(HTTP_OK, undef, HTTP::Headers->new(
$hal->http_headers,
), $hal->as_json);
$c->response->headers($response->headers);
$c->response->header(Preference_Applied => 'return=representation');
$c->response->header(Location => sprintf('%s%s', $self->dispatch_path, $item->id));
$c->response->body($response->content);
}
} else { } else {
my $hal = $self->hal_from_item($c, $item, $form); $c->response->status(HTTP_NO_CONTENT);
my $response = HTTP::Response->new(HTTP_OK, undef, HTTP::Headers->new( $c->response->body(q());
$hal->http_headers,
), $hal->as_json);
$c->response->headers($response->headers);
$c->response->header(Preference_Applied => 'return=representation');
$c->response->header(Location => sprintf('%s%s', $self->dispatch_path, $item->id));
$c->response->body($response->content);
} }
} }
@ -152,22 +156,26 @@ sub PUT :Allow {
last unless $txn_ok; last unless $txn_ok;
$item = $self->fetch_item($c, $resource, $form, $item); $item = $self->fetch_item($c, $resource, $form, $item);
last unless $item;
if ('minimal' eq $preference) { if ($item) {
$c->response->status(HTTP_NO_CONTENT); if ('minimal' eq $preference) {
$c->response->header(Preference_Applied => 'return=minimal'); $c->response->status(HTTP_NO_CONTENT);
$c->response->header(Location => sprintf('%s%s', $self->dispatch_path, $item->id)); $c->response->header(Preference_Applied => 'return=minimal');
$c->response->body(q()); $c->response->header(Location => sprintf('%s%s', $self->dispatch_path, $item->id));
$c->response->body(q());
} else {
my $hal = $self->hal_from_item($c, $item, $form);
my $response = HTTP::Response->new(HTTP_OK, undef, HTTP::Headers->new(
$hal->http_headers,
), $hal->as_json);
$c->response->headers($response->headers);
$c->response->header(Preference_Applied => 'return=representation');
$c->response->header(Location => sprintf('%s%s', $self->dispatch_path, $item->id));
$c->response->body($response->content);
}
} else { } else {
my $hal = $self->hal_from_item($c, $item, $form); $c->response->status(HTTP_NO_CONTENT);
my $response = HTTP::Response->new(HTTP_OK, undef, HTTP::Headers->new( $c->response->body(q());
$hal->http_headers,
), $hal->as_json);
$c->response->headers($response->headers);
$c->response->header(Preference_Applied => 'return=representation');
$c->response->header(Location => sprintf('%s%s', $self->dispatch_path, $item->id));
$c->response->body($response->content);
} }
} }
@ -195,7 +203,7 @@ sub delete_item {
return unless($sub); return unless($sub);
NGCP::Panel::Utils::Kamailio::delete_location_contact($c, NGCP::Panel::Utils::Kamailio::delete_location_contact($c,
$sub, $item->contact); $sub, $item->contact);
NGCP::Panel::Utils::Kamailio::flush($c); NGCP::Panel::Utils::Kamailio::flush($c) unless $self->suppress_flush($c);
return 1; return 1;
} }

@ -229,7 +229,7 @@ sub update_item {
$sub->provisioning_voip_subscriber, $sub->provisioning_voip_subscriber,
$values $values
); );
NGCP::Panel::Utils::Kamailio::flush($c); NGCP::Panel::Utils::Kamailio::flush($c) unless $self->suppress_flush($c);
return $item; return $item;
} }
@ -270,6 +270,19 @@ sub fetch_item {
return $item; return $item;
} }
sub suppress_flush {
my ($self, $c) = @_;
my $suppress_flush = $c->req->param('suppress_flush');
if (length($suppress_flush)
and ('1' eq $suppress_flush
or 'true' eq lc($suppress_flush))) {
return 1;
}
return 0;
}
sub valid_id { sub valid_id {
my ($self, $id) = @_; my ($self, $id) = @_;
if (defined $id && length $id > 0) { if (defined $id && length $id > 0) {

Loading…
Cancel
Save