From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH v1 1/1] box: fix custom delimiter for telnet connection
Date: Tue, 5 Mar 2019 16:43:04 +0300 [thread overview]
Message-ID: <20190305134303.ndcovkmiritgpdwp@tkn_work_nb> (raw)
In-Reply-To: <e61f08660a5010156c0bd940d07ba0d27828bf75.1550734259.git.kshcherbatov@tarantool.org>
This patch looks good for me, except several minor things.
Can we write a test for the new behaviour?
WBR, Alexander Turenko.
On Thu, Feb 21, 2019 at 10:34:55AM +0300, Kirill Shcherbatov wrote:
> Because test-run uses a console connection to run tests, the
> actual string delimiter was the user-specified delimiter
> delim + "\n".
'test-run uses a console connection' says nothing about why a newline is
added to a delimiter. I would say:
In order to give a user ability to use a delimiter symbol within a
code the real delimiter is user-provided 'delim' plus '\n'.
> Since telnet sends \r\n on line break, the updated expression
> delim + "\n"could not be found in a sequence data+delim+"\r\n",
Forgotten whitespace after the first "\n".
> so delimiter feature did not work at all.
> Added delim + "\r" check along with delim + "\n", that solves the
> described problem and does not violate backward compatibility.
>
> Closes #2027
>
> https://github.com/tarantool/tarantool/tree/kshch/gh-2027-telnet-alternative-delimiter
> https://github.com/tarantool/tarantool/issues/2027
> ---
> src/box/lua/console.lua | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
> index 028001127..bdedcb393 100644
> --- a/src/box/lua/console.lua
> +++ b/src/box/lua/console.lua
> @@ -344,8 +344,9 @@ end
> -- Read command from connected client console.listen()
> --
> local function client_read(self)
> - local delim = self.delimiter .. "\n"
> - local buf = self.client:read(delim)
> + local delim_lf = self.delimiter .. "\n"
> + local delim_cr = self.delimiter .. "\r"
I would comment here why we need delim_cr (in short).
> + local buf = self.client:read({delimiter = {delim_lf, delim_cr}})
> if buf == nil then
> return nil
> elseif buf == "" then
> @@ -355,7 +356,7 @@ local function client_read(self)
> return nil
> end
> -- remove trailing delimiter
> - return buf:sub(1, -#delim-1)
> + return buf:sub(1, -#delim_lf-1)
I would use `-#self.delimiter` to make the code simmetric btw delim_cr /
delim_lf.
> end
>
> --
> --
> 2.20.1
>
next prev parent reply other threads:[~2019-03-05 13:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 7:34 [tarantool-patches] " Kirill Shcherbatov
2019-03-05 13:43 ` Alexander Turenko [this message]
2019-03-05 14:41 ` [tarantool-patches] " Kirill Shcherbatov
2019-03-05 16:12 ` Alexander Turenko
2019-03-07 10:16 ` Kirill Yukhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190305134303.ndcovkmiritgpdwp@tkn_work_nb \
--to=alexander.turenko@tarantool.org \
--cc=kshcherbatov@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH v1 1/1] box: fix custom delimiter for telnet connection' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox