From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id C83ED2639E for ; Thu, 21 Feb 2019 02:35:00 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7WZfoMxI0FUF for ; Thu, 21 Feb 2019 02:35:00 -0500 (EST) Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [94.100.177.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 955A1262A3 for ; Thu, 21 Feb 2019 02:34:59 -0500 (EST) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v1 1/1] box: fix custom delimiter for telnet connection Date: Thu, 21 Feb 2019 10:34:55 +0300 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org, alexander.turenko@tarantool.org Cc: Kirill Shcherbatov Because test-run uses a console connection to run tests, the actual string delimiter was the user-specified delimiter delim + "\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", 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" + 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) end -- -- 2.20.1