From 0b0c61f4a51c8ccad34f6480ab9c92036532889a Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 10 Jan 2022 12:19:08 +0300 Subject: [PATCH] [#1063] node/object: Do not skip empty search responses in splitter In previous implementation `Search` method of transport splitter skipped responses with empty ID list. Replace while-loop with do-while one in `TransportSplitter.Search` method implementation in order to send responses with empty result too. Signed-off-by: Leonard Lyubich --- pkg/services/object/transport_splitter.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/services/object/transport_splitter.go b/pkg/services/object/transport_splitter.go index b3c48647..2ef4dcb4 100644 --- a/pkg/services/object/transport_splitter.go +++ b/pkg/services/object/transport_splitter.go @@ -154,7 +154,7 @@ func (s *searchStreamMsgSizeCtrl) Send(resp *object.SearchResponse) error { var newResp *object.SearchResponse - for ln := uint64(len(ids)); len(ids) > 0; { + for ln := uint64(len(ids)); ; { if newResp == nil { newResp = new(object.SearchResponse) newResp.SetBody(body) @@ -174,6 +174,10 @@ func (s *searchStreamMsgSizeCtrl) Send(resp *object.SearchResponse) error { } ids = ids[cut:] + + if len(ids) == 0 { + break + } } return nil