From b5e2871aa0bd9b72bef96811201551af8ed7bdff Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 30 Aug 2022 21:36:43 +0530 Subject: [PATCH] Remove not needed chunking code --- tools/cmd/at/main.go | 23 +++-------------------- tools/cmd/at/socket_io.go | 2 +- tools/cmd/at/tty_io.go | 4 ++-- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/tools/cmd/at/main.go b/tools/cmd/at/main.go index 8c9fa3371..6cf36b8dd 100644 --- a/tools/cmd/at/main.go +++ b/tools/cmd/at/main.go @@ -97,6 +97,7 @@ func (self *wrapped_serializer) next(io_data *rc_io_data) ([]byte, error) { } else { self.all_payloads_done = true } + self.state++ return self.serializer(io_data.rc) case 2: if self.all_payloads_done { @@ -168,33 +169,15 @@ type rc_io_data struct { string_response_is_err bool timeout time.Duration multiple_payload_generator func(io_data *rc_io_data) (bool, error) - - pending_chunks [][]byte } -func (self *rc_io_data) next_chunk(limit_size bool) (chunk []byte, err error) { - if len(self.pending_chunks) > 0 { - chunk = self.pending_chunks[0] - copy(self.pending_chunks, self.pending_chunks[1:]) - self.pending_chunks = self.pending_chunks[:len(self.pending_chunks)-1] - return - } +func (self *rc_io_data) next_chunk() (chunk []byte, err error) { block, err := self.serializer.next(self) if err != nil && !errors.Is(err, io.EOF) { return } err = nil - const limit = 2048 - if !limit_size || len(block) < limit { - chunk = block - return - } - chunk = block[:limit] - block = block[limit:] - for len(block) > 0 { - self.pending_chunks = append(self.pending_chunks, block[:limit]) - block = block[limit:] - } + chunk = block return } diff --git a/tools/cmd/at/socket_io.go b/tools/cmd/at/socket_io.go index 2ed9d7359..9fc55db5d 100644 --- a/tools/cmd/at/socket_io.go +++ b/tools/cmd/at/socket_io.go @@ -54,7 +54,7 @@ func read_response_from_conn(conn *net.Conn, timeout time.Duration) (serialized_ func simple_socket_io(conn *net.Conn, io_data *rc_io_data) (serialized_response []byte, err error) { for { var chunk []byte - chunk, err = io_data.next_chunk(false) + chunk, err = io_data.next_chunk() if err != nil { return } diff --git a/tools/cmd/at/tty_io.go b/tools/cmd/at/tty_io.go index f86616b2a..ed9efd8d4 100644 --- a/tools/cmd/at/tty_io.go +++ b/tools/cmd/at/tty_io.go @@ -44,7 +44,7 @@ func do_chunked_io(io_data *rc_io_data) (serialized_response []byte, err error) } lp.OnInitialize = func() (string, error) { - chunk, err := io_data.next_chunk(false) + chunk, err := io_data.next_chunk() if err != nil { return "", err } @@ -62,7 +62,7 @@ func do_chunked_io(io_data *rc_io_data) (serialized_response []byte, err error) } return nil } - chunk, err := io_data.next_chunk(false) + chunk, err := io_data.next_chunk() if err != nil { return err }