[PATCH 1/1] netbox: raise an error on a closed connection async call

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Feb 19 15:44:53 MSK 2019


When a connection is closed, it should not allow any
requests - async and not. But before this patch this error
from netbox.perform_async_request was ignored.
---
Branch: https://github.com/tarantool/tarantool/tree/gerold103/fix-netbox-async-call

 src/box/lua/net_box.lua   | 9 +++++++--
 test/box/net.box.result   | 7 +++++++
 test/box/net.box.test.lua | 5 +++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index 2bf772aa8..b3139a3f5 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -1056,8 +1056,13 @@ function remote_methods:_request(method, opts, ...)
             if opts.on_push or opts.on_push_ctx then
                 error('To handle pushes in an async request use future:pairs()')
             end
-            return transport.perform_async_request(buffer, method, table.insert,
-                                                   {}, ...)
+            local res, err =
+                transport.perform_async_request(buffer, method, table.insert,
+                                                {}, ...)
+            if err then
+                box.error(err)
+            end
+            return res
         end
         if opts.timeout then
             -- conn.space:request(, { timeout = timeout })
diff --git a/test/box/net.box.result b/test/box/net.box.result
index 2b5a84646..6351898b3 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -2836,6 +2836,13 @@ future:wait_result(100)
 c:close()
 ---
 ...
+--
+-- Check that is_async does not work on a closed connection.
+--
+c:call('any_func', {}, {is_async = true})
+---
+- error: Connection closed
+...
 box.schema.user.revoke('guest', 'execute', 'universe')
 ---
 ...
diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua
index 96d822820..6c527f506 100644
--- a/test/box/net.box.test.lua
+++ b/test/box/net.box.test.lua
@@ -1161,6 +1161,11 @@ finalize_long()
 future:wait_result(100)
 
 c:close()
+--
+-- Check that is_async does not work on a closed connection.
+--
+c:call('any_func', {}, {is_async = true})
+
 box.schema.user.revoke('guest', 'execute', 'universe')
 c = net:connect(box.cfg.listen)
 
-- 
2.17.2 (Apple Git-113)




More information about the Tarantool-patches mailing list