* [Tarantool-patches] [PATCH 1/1] console: fix usage of an undeclared variable
@ 2019-10-17 19:50 Vladislav Shpilevoy
2019-10-17 20:00 ` Cyrill Gorcunov
2019-10-17 21:06 ` [Tarantool-patches] " Alexander Turenko
0 siblings, 2 replies; 12+ messages in thread
From: Vladislav Shpilevoy @ 2019-10-17 19:50 UTC (permalink / raw)
To: tarantool-patches; +Cc: tarantool-patches
Console client's eval() method in case of an error at
reading from a socket was trying to return a variable
declared in a different view scope. Instead, the
error should be raised to drop the connection.
---
Branch: https://github.com/tarantool/tarantool/tree/gerold103/console-undefined-variable
No test, because can be reproduced only in repl mode of a client.
src/box/lua/console.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
index f70ed830a..52df67465 100644
--- a/src/box/lua/console.lua
+++ b/src/box/lua/console.lua
@@ -451,7 +451,7 @@ local text_connection_mt = {
self.print_f(rc)
end
end
- return rc
+ return error(self:set_error())
end,
--
-- Make the connection be in error state, set error
--
2.21.0 (Apple Git-122)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 19:50 [Tarantool-patches] [PATCH 1/1] console: fix usage of an undeclared variable Vladislav Shpilevoy
@ 2019-10-17 20:00 ` Cyrill Gorcunov
2019-10-17 20:31 ` [Tarantool-patches] [tarantool-patches] " Vladislav Shpilevoy
2019-10-17 21:06 ` [Tarantool-patches] " Alexander Turenko
1 sibling, 1 reply; 12+ messages in thread
From: Cyrill Gorcunov @ 2019-10-17 20:00 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches, tarantool-patches
On Thu, Oct 17, 2019 at 09:50:44PM +0200, Vladislav Shpilevoy wrote:
> Console client's eval() method in case of an error at
> reading from a socket was trying to return a variable
> declared in a different view scope. Instead, the
> error should be raised to drop the connection.
> ---
> Branch: https://github.com/tarantool/tarantool/tree/gerold103/console-undefined-variable
>
> No test, because can be reproduced only in repl mode of a client.
>
> src/box/lua/console.lua | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
> index f70ed830a..52df67465 100644
> --- a/src/box/lua/console.lua
> +++ b/src/box/lua/console.lua
> @@ -451,7 +451,7 @@ local text_connection_mt = {
> self.print_f(rc)
> end
> end
> - return rc
> + return error(self:set_error())
Wait
...
local rc = self:read()
if not rc then
break
end
...
We're reading from a socket and there could be EOF, which will
give us zero return code. But now we will start to yielding
an error in this case.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 20:00 ` Cyrill Gorcunov
@ 2019-10-17 20:31 ` Vladislav Shpilevoy
2019-10-17 21:05 ` Cyrill Gorcunov
0 siblings, 1 reply; 12+ messages in thread
From: Vladislav Shpilevoy @ 2019-10-17 20:31 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: tarantool-patches, tarantool-patches
On 17/10/2019 22:00, Cyrill Gorcunov wrote:
> On Thu, Oct 17, 2019 at 09:50:44PM +0200, Vladislav Shpilevoy wrote:
>> Console client's eval() method in case of an error at
>> reading from a socket was trying to return a variable
>> declared in a different view scope. Instead, the
>> error should be raised to drop the connection.
>> ---
>> Branch: https://github.com/tarantool/tarantool/tree/gerold103/console-undefined-variable
>>
>> No test, because can be reproduced only in repl mode of a client.
>>
>> src/box/lua/console.lua | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
>> index f70ed830a..52df67465 100644
>> --- a/src/box/lua/console.lua
>> +++ b/src/box/lua/console.lua
>> @@ -451,7 +451,7 @@ local text_connection_mt = {
>> self.print_f(rc)
>> end
>> end
>> - return rc
>> + return error(self:set_error())
>
> Wait
> ...
> local rc = self:read()
> if not rc then
> break
> end
> ...
>
> We're reading from a socket and there could be EOF, which will
> give us zero return code. But now we will start to yielding
> an error in this case.
>
set_error is aware of that. It says 'Peer closed' on EOF.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 20:31 ` [Tarantool-patches] [tarantool-patches] " Vladislav Shpilevoy
@ 2019-10-17 21:05 ` Cyrill Gorcunov
2019-10-17 21:08 ` Cyrill Gorcunov
0 siblings, 1 reply; 12+ messages in thread
From: Cyrill Gorcunov @ 2019-10-17 21:05 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches, tarantool-patches
On Thu, Oct 17, 2019 at 10:31:00PM +0200, Vladislav Shpilevoy wrote:
> >
> > We're reading from a socket and there could be EOF, which will
> > give us zero return code. But now we will start to yielding
> > an error in this case.
> >
>
> set_error is aware of that. It says 'Peer closed' on EOF.
Looks reasonable enough. Thanks!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 21:05 ` Cyrill Gorcunov
@ 2019-10-17 21:08 ` Cyrill Gorcunov
2019-10-17 21:18 ` Vladislav Shpilevoy
0 siblings, 1 reply; 12+ messages in thread
From: Cyrill Gorcunov @ 2019-10-17 21:08 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches, tarantool-patches
On Fri, Oct 18, 2019 at 12:05:05AM +0300, Cyrill Gorcunov wrote:
> On Thu, Oct 17, 2019 at 10:31:00PM +0200, Vladislav Shpilevoy wrote:
> > >
> > > We're reading from a socket and there could be EOF, which will
> > > give us zero return code. But now we will start to yielding
> > > an error in this case.
> > >
> >
> > set_error is aware of that. It says 'Peer closed' on EOF.
>
> Looks reasonable enough. Thanks!
Still (if only I'm not missing something obvious) this changes
api a bit -- previously we've been returning empty string for
this case but now we will print 'Peer closed', hopefully this
won't be a problem though.
Cyrill
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 21:08 ` Cyrill Gorcunov
@ 2019-10-17 21:18 ` Vladislav Shpilevoy
2019-10-17 21:15 ` Cyrill Gorcunov
0 siblings, 1 reply; 12+ messages in thread
From: Vladislav Shpilevoy @ 2019-10-17 21:18 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: tarantool-patches, tarantool-patches
On 17/10/2019 23:08, Cyrill Gorcunov wrote:
> On Fri, Oct 18, 2019 at 12:05:05AM +0300, Cyrill Gorcunov wrote:
>> On Thu, Oct 17, 2019 at 10:31:00PM +0200, Vladislav Shpilevoy wrote:
>>>>
>>>> We're reading from a socket and there could be EOF, which will
>>>> give us zero return code. But now we will start to yielding
>>>> an error in this case.
>>>>
>>>
>>> set_error is aware of that. It says 'Peer closed' on EOF.
>>
>> Looks reasonable enough. Thanks!
>
> Still (if only I'm not missing something obvious) this changes
> api a bit -- previously we've been returning empty string for
> this case but now we will print 'Peer closed', hopefully this
> won't be a problem though.
>
> Cyrill
>
Previously there was an error about undeclared variable.
'return rc'
Here 'rc' was not declared.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 21:18 ` Vladislav Shpilevoy
@ 2019-10-17 21:15 ` Cyrill Gorcunov
2019-10-17 21:22 ` Vladislav Shpilevoy
0 siblings, 1 reply; 12+ messages in thread
From: Cyrill Gorcunov @ 2019-10-17 21:15 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches, tarantool-patches
On Thu, Oct 17, 2019 at 11:18:22PM +0200, Vladislav Shpilevoy wrote:
> Previously there was an error about undeclared variable.
>
> 'return rc'
>
> Here 'rc' was not declared.
Yes, and it means we will get nil here, and the caller code
threat it as no-error and return empty string upward.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 21:15 ` Cyrill Gorcunov
@ 2019-10-17 21:22 ` Vladislav Shpilevoy
2019-10-17 21:19 ` Cyrill Gorcunov
0 siblings, 1 reply; 12+ messages in thread
From: Vladislav Shpilevoy @ 2019-10-17 21:22 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: tarantool-patches, tarantool-patches
On 17/10/2019 23:15, Cyrill Gorcunov wrote:
> On Thu, Oct 17, 2019 at 11:18:22PM +0200, Vladislav Shpilevoy wrote:
>> Previously there was an error about undeclared variable.
>>
>> 'return rc'
>>
>> Here 'rc' was not declared.
>
> Yes, and it means we will get nil here, and the caller code
> threat it as no-error and return empty string upward.
>
No, it was not nil. It was:
localhost:3313>
---
- error: 'builtin/box/console.lua:454: variable ''rc'' is not declared'
...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 21:22 ` Vladislav Shpilevoy
@ 2019-10-17 21:19 ` Cyrill Gorcunov
2019-10-17 21:26 ` Vladislav Shpilevoy
0 siblings, 1 reply; 12+ messages in thread
From: Cyrill Gorcunov @ 2019-10-17 21:19 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches, tarantool-patches
On Thu, Oct 17, 2019 at 11:22:56PM +0200, Vladislav Shpilevoy wrote:
> > Yes, and it means we will get nil here, and the caller code
> > threat it as no-error and return empty string upward.
>
> No, it was not nil. It was:
>
> localhost:3313>
> ---
> - error: 'builtin/box/console.lua:454: variable ''rc'' is not declared'
> ...
Aha! I happen to miss that. Thanks for the point!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 21:19 ` Cyrill Gorcunov
@ 2019-10-17 21:26 ` Vladislav Shpilevoy
2019-10-17 21:31 ` Cyrill Gorcunov
0 siblings, 1 reply; 12+ messages in thread
From: Vladislav Shpilevoy @ 2019-10-17 21:26 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: tarantool-patches, tarantool-patches
On 17/10/2019 23:19, Cyrill Gorcunov wrote:
> On Thu, Oct 17, 2019 at 11:22:56PM +0200, Vladislav Shpilevoy wrote:
>>> Yes, and it means we will get nil here, and the caller code
>>> threat it as no-error and return empty string upward.
>>
>> No, it was not nil. It was:
>>
>> localhost:3313>
>> ---
>> - error: 'builtin/box/console.lua:454: variable ''rc'' is not declared'
>> ...
>
> Aha! I happen to miss that. Thanks for the point!
>
It would be nil in case a user turned strict mode off.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 21:26 ` Vladislav Shpilevoy
@ 2019-10-17 21:31 ` Cyrill Gorcunov
0 siblings, 0 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2019-10-17 21:31 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches, tarantool-patches
On Thu, Oct 17, 2019 at 11:26:04PM +0200, Vladislav Shpilevoy wrote:
> >> localhost:3313>
> >> ---
> >> - error: 'builtin/box/console.lua:454: variable ''rc'' is not declared'
> >> ...
> >
> > Aha! I happen to miss that. Thanks for the point!
>
> It would be nil in case a user turned strict mode off.
I see, thanks for explanation.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Tarantool-patches] [PATCH 1/1] console: fix usage of an undeclared variable
2019-10-17 19:50 [Tarantool-patches] [PATCH 1/1] console: fix usage of an undeclared variable Vladislav Shpilevoy
2019-10-17 20:00 ` Cyrill Gorcunov
@ 2019-10-17 21:06 ` Alexander Turenko
1 sibling, 0 replies; 12+ messages in thread
From: Alexander Turenko @ 2019-10-17 21:06 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches, tarantool-patches
LGTM.
Pushed to master, 2.2, 2.1 and 1.10.
WBR, Alexander Turenko.
On Thu, Oct 17, 2019 at 09:50:44PM +0200, Vladislav Shpilevoy wrote:
> Console client's eval() method in case of an error at
> reading from a socket was trying to return a variable
> declared in a different view scope. Instead, the
> error should be raised to drop the connection.
> ---
> Branch: https://github.com/tarantool/tarantool/tree/gerold103/console-undefined-variable
>
> No test, because can be reproduced only in repl mode of a client.
>
> src/box/lua/console.lua | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
> index f70ed830a..52df67465 100644
> --- a/src/box/lua/console.lua
> +++ b/src/box/lua/console.lua
> @@ -451,7 +451,7 @@ local text_connection_mt = {
> self.print_f(rc)
> end
> end
> - return rc
> + return error(self:set_error())
> end,
> --
> -- Make the connection be in error state, set error
> --
> 2.21.0 (Apple Git-122)
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-10-17 21:31 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17 19:50 [Tarantool-patches] [PATCH 1/1] console: fix usage of an undeclared variable Vladislav Shpilevoy
2019-10-17 20:00 ` Cyrill Gorcunov
2019-10-17 20:31 ` [Tarantool-patches] [tarantool-patches] " Vladislav Shpilevoy
2019-10-17 21:05 ` Cyrill Gorcunov
2019-10-17 21:08 ` Cyrill Gorcunov
2019-10-17 21:18 ` Vladislav Shpilevoy
2019-10-17 21:15 ` Cyrill Gorcunov
2019-10-17 21:22 ` Vladislav Shpilevoy
2019-10-17 21:19 ` Cyrill Gorcunov
2019-10-17 21:26 ` Vladislav Shpilevoy
2019-10-17 21:31 ` Cyrill Gorcunov
2019-10-17 21:06 ` [Tarantool-patches] " Alexander Turenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox